2011-01-01 23:24:51 +00:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2011-01-01 23:24:51 +00:00
|
|
|
namespace Symfony\Tests\Component\Form;
|
|
|
|
|
|
|
|
use Symfony\Component\Form\LocaleField;
|
2011-01-19 12:43:24 +00:00
|
|
|
use Symfony\Component\Form\FormContext;
|
2011-01-01 23:24:51 +00:00
|
|
|
|
|
|
|
class LocaleFieldTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testLocalesAreSelectable()
|
|
|
|
{
|
2011-01-19 12:43:24 +00:00
|
|
|
FormContext::setLocale('de_AT');
|
2011-01-01 23:24:51 +00:00
|
|
|
|
|
|
|
$field = new LocaleField('language');
|
|
|
|
$choices = $field->getOtherChoices();
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('en', $choices);
|
|
|
|
$this->assertEquals('Englisch', $choices['en']);
|
|
|
|
$this->assertArrayHasKey('en_GB', $choices);
|
|
|
|
$this->assertEquals('Englisch (Vereinigtes Königreich)', $choices['en_GB']);
|
|
|
|
$this->assertArrayHasKey('zh_Hans_MO', $choices);
|
|
|
|
$this->assertEquals('Chinesisch (vereinfacht, Sonderverwaltungszone Macao)', $choices['zh_Hans_MO']);
|
|
|
|
}
|
2011-01-21 18:04:20 +00:00
|
|
|
|
|
|
|
public function testEmptyValueOption()
|
|
|
|
{
|
|
|
|
// empty_value false
|
|
|
|
$field = new LocaleField('language', array('empty_value' => false));
|
|
|
|
$choices = $field->getOtherChoices();
|
|
|
|
$this->assertArrayNotHasKey('', $choices);
|
|
|
|
|
|
|
|
// empty_value as a blank string
|
|
|
|
$field = new LocaleField('language', array('empty_value' => ''));
|
|
|
|
$choices = $field->getOtherChoices();
|
|
|
|
$this->assertArrayHasKey('', $choices);
|
|
|
|
$this->assertEquals('', $choices['']);
|
|
|
|
|
|
|
|
// empty_value as a normal string
|
|
|
|
$field = new LocaleField('language', array('empty_value' => 'Choose a locale'));
|
|
|
|
$choices = $field->getOtherChoices();
|
|
|
|
$this->assertArrayHasKey('', $choices);
|
|
|
|
$this->assertEquals('Choose a locale', $choices['']);
|
|
|
|
}
|
2011-01-01 23:24:51 +00:00
|
|
|
}
|