LanguageFieldTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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. require_once __DIR__.'/TestCase.php';
  12. use Symfony\Component\Form\LanguageField;
  13. use Symfony\Component\Form\FormContext;
  14. class LanguageFieldTest extends TestCase
  15. {
  16. public function testCountriesAreSelectable()
  17. {
  18. \Locale::setDefault('de_AT');
  19. $field = $this->factory->getLanguageField('language');
  20. $choices = $field->getRenderer()->getVar('choices');
  21. $this->assertArrayHasKey('en', $choices);
  22. $this->assertEquals('Englisch', $choices['en']);
  23. $this->assertArrayHasKey('en_GB', $choices);
  24. $this->assertEquals('Britisches Englisch', $choices['en_GB']);
  25. $this->assertArrayHasKey('en_US', $choices);
  26. $this->assertEquals('Amerikanisches Englisch', $choices['en_US']);
  27. $this->assertArrayHasKey('fr', $choices);
  28. $this->assertEquals('Französisch', $choices['fr']);
  29. $this->assertArrayHasKey('my', $choices);
  30. $this->assertEquals('Birmanisch', $choices['my']);
  31. }
  32. public function testMultipleLanguagesIsNotIncluded()
  33. {
  34. $field = $this->factory->getLanguageField('language');
  35. $choices = $field->getRenderer()->getVar('choices');
  36. $this->assertArrayNotHasKey('mul', $choices);
  37. }
  38. }