CountryFieldTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. require_once __DIR__.'/TestCase.php';
  14. class CountryFieldTest extends TestCase
  15. {
  16. public function testCountriesAreSelectable()
  17. {
  18. \Locale::setDefault('de_AT');
  19. $field = $this->factory->create('country', 'country');
  20. $choices = $field->getRenderer()->getVar('choices');
  21. $this->assertArrayHasKey('DE', $choices);
  22. $this->assertEquals('Deutschland', $choices['DE']);
  23. $this->assertArrayHasKey('GB', $choices);
  24. $this->assertEquals('Vereinigtes Königreich', $choices['GB']);
  25. $this->assertArrayHasKey('US', $choices);
  26. $this->assertEquals('Vereinigte Staaten', $choices['US']);
  27. $this->assertArrayHasKey('FR', $choices);
  28. $this->assertEquals('Frankreich', $choices['FR']);
  29. $this->assertArrayHasKey('MY', $choices);
  30. $this->assertEquals('Malaysia', $choices['MY']);
  31. }
  32. public function testUnknownCountryIsNotIncluded()
  33. {
  34. $field = $this->factory->create('country', 'country');
  35. $choices = $field->getRenderer()->getVar('choices');
  36. $this->assertArrayNotHasKey('ZZ', $choices);
  37. }
  38. }