CountryFieldTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Form;
  11. use Symfony\Component\Form\CountryField;
  12. use Symfony\Component\Form\FormContext;
  13. class CountryFieldTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testCountriesAreSelectable()
  16. {
  17. \Locale::setDefault('de_AT');
  18. $field = new CountryField('country');
  19. $choices = $field->getOtherChoices();
  20. $this->assertArrayHasKey('DE', $choices);
  21. $this->assertEquals('Deutschland', $choices['DE']);
  22. $this->assertArrayHasKey('GB', $choices);
  23. $this->assertEquals('Vereinigtes Königreich', $choices['GB']);
  24. $this->assertArrayHasKey('US', $choices);
  25. $this->assertEquals('Vereinigte Staaten', $choices['US']);
  26. $this->assertArrayHasKey('FR', $choices);
  27. $this->assertEquals('Frankreich', $choices['FR']);
  28. $this->assertArrayHasKey('MY', $choices);
  29. $this->assertEquals('Malaysia', $choices['MY']);
  30. }
  31. public function testUnknownCountryIsNotIncluded()
  32. {
  33. $field = new CountryField('country');
  34. $choices = $field->getOtherChoices();
  35. $this->assertArrayNotHasKey('ZZ', $choices);
  36. }
  37. }