2010-12-15 16:44:36 +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 16:44:36 +00:00
|
|
|
namespace Symfony\Tests\Component\Form;
|
|
|
|
|
|
|
|
use Symfony\Component\Form\CountryField;
|
2011-01-19 12:43:24 +00:00
|
|
|
use Symfony\Component\Form\FormContext;
|
2010-12-15 16:44:36 +00:00
|
|
|
|
2011-02-21 23:09:44 +00:00
|
|
|
require_once __DIR__.'/TestCase.php';
|
|
|
|
|
|
|
|
class CountryFieldTest extends TestCase
|
2010-12-15 16:44:36 +00:00
|
|
|
{
|
|
|
|
public function testCountriesAreSelectable()
|
|
|
|
{
|
2011-01-31 14:15:12 +00:00
|
|
|
\Locale::setDefault('de_AT');
|
2010-12-15 16:44:36 +00:00
|
|
|
|
2011-03-02 11:20:30 +00:00
|
|
|
$field = $this->factory->getInstance('country', 'country');
|
2011-02-21 23:09:44 +00:00
|
|
|
$choices = $field->getRenderer()->getVar('choices');
|
2010-12-15 16:44:36 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey('DE', $choices);
|
|
|
|
$this->assertEquals('Deutschland', $choices['DE']);
|
|
|
|
$this->assertArrayHasKey('GB', $choices);
|
|
|
|
$this->assertEquals('Vereinigtes Königreich', $choices['GB']);
|
|
|
|
$this->assertArrayHasKey('US', $choices);
|
|
|
|
$this->assertEquals('Vereinigte Staaten', $choices['US']);
|
|
|
|
$this->assertArrayHasKey('FR', $choices);
|
|
|
|
$this->assertEquals('Frankreich', $choices['FR']);
|
|
|
|
$this->assertArrayHasKey('MY', $choices);
|
|
|
|
$this->assertEquals('Malaysia', $choices['MY']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnknownCountryIsNotIncluded()
|
|
|
|
{
|
2011-03-02 11:20:30 +00:00
|
|
|
$field = $this->factory->getInstance('country', 'country');
|
2011-02-21 23:09:44 +00:00
|
|
|
$choices = $field->getRenderer()->getVar('choices');
|
2010-12-15 16:44:36 +00:00
|
|
|
|
|
|
|
$this->assertArrayNotHasKey('ZZ', $choices);
|
|
|
|
}
|
|
|
|
}
|