CountryFieldTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Symfony\Tests\Component\Form;
  3. use Symfony\Component\Form\CountryField;
  4. use Symfony\Component\Form\FormConfiguration;
  5. class CountryFieldTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testCountriesAreSelectable()
  8. {
  9. FormConfiguration::setDefaultLocale('de_AT');
  10. $field = new CountryField('country');
  11. $choices = $field->getOtherChoices();
  12. $this->assertArrayHasKey('DE', $choices);
  13. $this->assertEquals('Deutschland', $choices['DE']);
  14. $this->assertArrayHasKey('GB', $choices);
  15. $this->assertEquals('Vereinigtes Königreich', $choices['GB']);
  16. $this->assertArrayHasKey('US', $choices);
  17. $this->assertEquals('Vereinigte Staaten', $choices['US']);
  18. $this->assertArrayHasKey('FR', $choices);
  19. $this->assertEquals('Frankreich', $choices['FR']);
  20. $this->assertArrayHasKey('MY', $choices);
  21. $this->assertEquals('Malaysia', $choices['MY']);
  22. }
  23. public function testUnknownCountryIsNotIncluded()
  24. {
  25. $field = new CountryField('country');
  26. $choices = $field->getOtherChoices();
  27. $this->assertArrayNotHasKey('ZZ', $choices);
  28. }
  29. }