Decoupled Form component from intl extension

This commit is contained in:
Bernhard Schussek 2010-06-24 11:39:05 +02:00 committed by Fabien Potencier
parent bcd4b6d140
commit ca3dc31057
12 changed files with 35 additions and 10 deletions

View File

@ -42,7 +42,7 @@ abstract class Field extends Configurable implements FieldInterface
$this->addOption('property_path', (string)$key);
$this->key = (string)$key;
$this->locale = \Locale::getDefault();
$this->locale = class_exists('\Locale', false) ? \Locale::getDefault() : 'en';
$this->generator = new HtmlGenerator();
parent::__construct($options);

View File

@ -27,7 +27,7 @@ abstract class BaseValueTransformer extends Configurable implements ValueTransfo
*/
public function __construct(array $options = array())
{
$this->locale = \Locale::getDefault();
$this->locale = class_exists('\Locale', false) ? \Locale::getDefault() : 'en';
parent::__construct($options);
}

View File

@ -2,7 +2,9 @@
namespace Symfony\Tests\Components\Form;
class DateTimeTestCase extends \PHPUnit_Framework_TestCase
require_once __DIR__ . '/LocalizedTestCase.php';
class DateTimeTestCase extends LocalizedTestCase
{
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
{

View File

@ -634,7 +634,7 @@ class FieldGroupTest extends \PHPUnit_Framework_TestCase
$group->add($field);
$group->setLocale('de_DE');
$this->assertEquals(array(\Locale::getDefault(), 'de_DE'), $field->locales);
$this->assertEquals(array(class_exists('\Locale', false) ? \Locale::getDefault() : 'en', 'de_DE'), $field->locales);
}
public function testTranslatorIsPassedToField_SetBeforeAddingTheField()

View File

@ -3,10 +3,11 @@
namespace Symfony\Tests\Components\Form;
require_once __DIR__ . '/../../../../bootstrap.php';
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Components\Form\IntegerField;
class IntegerFieldTest extends \PHPUnit_Framework_TestCase
class IntegerFieldTest extends LocalizedTestCase
{
public function testBindCastsToInteger()
{

View File

@ -0,0 +1,13 @@
<?php
namespace Symfony\Tests\Components\Form;
class LocalizedTestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('The "intl" extension is not available');
}
}
}

View File

@ -3,10 +3,11 @@
namespace Symfony\Tests\Components\Form;
require_once __DIR__ . '/../../../../bootstrap.php';
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Components\Form\MoneyField;
class MoneyFieldTest extends \PHPUnit_Framework_TestCase
class MoneyFieldTest extends LocalizedTestCase
{
public function testRenderWithoutCurrency()
{

View File

@ -3,10 +3,11 @@
namespace Symfony\Tests\Components\Form;
require_once __DIR__ . '/../../../../bootstrap.php';
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Components\Form\NumberField;
class NumberFieldTest extends \PHPUnit_Framework_TestCase
class NumberFieldTest extends LocalizedTestCase
{
public function testRender()
{

View File

@ -3,10 +3,11 @@
namespace Symfony\Tests\Components\Form;
require_once __DIR__ . '/../../../../bootstrap.php';
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Components\Form\PercentField;
class PercentFieldTest extends \PHPUnit_Framework_TestCase
class PercentFieldTest extends LocalizedTestCase
{
public function testRender()
{

View File

@ -15,6 +15,8 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
public function setUp()
{
parent::setUp();
$this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
$this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
}

View File

@ -3,11 +3,13 @@
namespace Symfony\Tests\Components\Form\ValueTransformer;
require_once __DIR__ . '/../../../../../bootstrap.php';
require_once __DIR__ . '/../LocalizedTestCase.php';
use Symfony\Components\Form\ValueTransformer\NumberToLocalizedStringTransformer;
use Symfony\Tests\Components\Form\LocalizedTestCase;
class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
{
public function testTransform()
{

View File

@ -3,11 +3,13 @@
namespace Symfony\Tests\Components\Form\ValueTransformer;
require_once __DIR__ . '/../../../../../bootstrap.php';
require_once __DIR__ . '/../LocalizedTestCase.php';
use Symfony\Components\Form\ValueTransformer\PercentToLocalizedStringTransformer;
use Symfony\Tests\Components\Form\LocalizedTestCase;
class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
{
public function testTransform()
{