Skip to content

Commit

Permalink
Fix ezcountry mapping to form
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofia Lescano committed Sep 21, 2018
1 parent 26f6131 commit 6514c5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions bundle/Form/FieldTypeHandler/Country.php
Expand Up @@ -61,12 +61,10 @@ public function convertFieldValueToForm(Value $value, FieldDefinition $fieldDefi

$keys = array_keys($value->countries);

return array(
$keys[0] => $value->countries[$keys[0]],
);
return reset($keys);
}

return $value->countries;
return array_keys($value->countries);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Form/FieldTypeHandler/CountryTest.php
Expand Up @@ -39,7 +39,7 @@ public function testConvertFieldValueToForm()

$returnedValue = $country->convertFieldValueToForm($countryValue);

$this->assertEquals($countries, $returnedValue);
$this->assertEquals(['HR'], $returnedValue);
}

public function testConvertFieldValueToFormMultipleValues()
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testConvertFieldValueToFormMultipleValues()

$returnedValue = $country->convertFieldValueToForm($countryValue, $fieldDefinition);

$this->assertEquals($selectedCountries, $returnedValue);
$this->assertEquals(['HR', 'BB'], $returnedValue);
}

public function testConvertFieldValueToFormSingleValue()
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testConvertFieldValueToFormSingleValue()

$returnedValue = $country->convertFieldValueToForm($countryValue, $fieldDefinition);

$this->assertEquals($selectedCountries, $returnedValue);
$this->assertEquals('HR', $returnedValue);
}

public function testConvertFieldValueToFormWithNoneSelected()
Expand Down

0 comments on commit 6514c5b

Please sign in to comment.