2010-12-15 17:29:20 +00:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-12-15 17:29:20 +00:00
|
|
|
namespace Symfony\Tests\Component\Form;
|
|
|
|
|
2011-02-21 23:09:44 +00:00
|
|
|
require_once __DIR__.'/TestCase.php';
|
|
|
|
|
2010-12-15 17:29:20 +00:00
|
|
|
use Symfony\Component\Form\LanguageField;
|
2011-01-19 12:43:24 +00:00
|
|
|
use Symfony\Component\Form\FormContext;
|
2010-12-15 17:29:20 +00:00
|
|
|
|
2011-02-21 23:09:44 +00:00
|
|
|
class LanguageFieldTest extends TestCase
|
2010-12-15 17:29:20 +00:00
|
|
|
{
|
|
|
|
public function testCountriesAreSelectable()
|
|
|
|
{
|
2011-01-31 14:15:12 +00:00
|
|
|
\Locale::setDefault('de_AT');
|
2010-12-15 17:29:20 +00:00
|
|
|
|
2011-03-02 11:20:30 +00:00
|
|
|
$field = $this->factory->getInstance('language', 'language');
|
2011-02-21 23:09:44 +00:00
|
|
|
$choices = $field->getRenderer()->getVar('choices');
|
2010-12-15 17:29:20 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey('en', $choices);
|
|
|
|
$this->assertEquals('Englisch', $choices['en']);
|
|
|
|
$this->assertArrayHasKey('en_GB', $choices);
|
|
|
|
$this->assertEquals('Britisches Englisch', $choices['en_GB']);
|
|
|
|
$this->assertArrayHasKey('en_US', $choices);
|
|
|
|
$this->assertEquals('Amerikanisches Englisch', $choices['en_US']);
|
|
|
|
$this->assertArrayHasKey('fr', $choices);
|
|
|
|
$this->assertEquals('Französisch', $choices['fr']);
|
|
|
|
$this->assertArrayHasKey('my', $choices);
|
|
|
|
$this->assertEquals('Birmanisch', $choices['my']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMultipleLanguagesIsNotIncluded()
|
|
|
|
{
|
2011-03-02 11:20:30 +00:00
|
|
|
$field = $this->factory->getInstance('language', 'language');
|
2011-02-21 23:09:44 +00:00
|
|
|
$choices = $field->getRenderer()->getVar('choices');
|
2010-12-15 17:29:20 +00:00
|
|
|
|
|
|
|
$this->assertArrayNotHasKey('mul', $choices);
|
|
|
|
}
|
|
|
|
}
|