Decoupled Form component from intl extension
This commit is contained in:
parent
bcd4b6d140
commit
ca3dc31057
|
@ -42,7 +42,7 @@ abstract class Field extends Configurable implements FieldInterface
|
||||||
$this->addOption('property_path', (string)$key);
|
$this->addOption('property_path', (string)$key);
|
||||||
|
|
||||||
$this->key = (string)$key;
|
$this->key = (string)$key;
|
||||||
$this->locale = \Locale::getDefault();
|
$this->locale = class_exists('\Locale', false) ? \Locale::getDefault() : 'en';
|
||||||
$this->generator = new HtmlGenerator();
|
$this->generator = new HtmlGenerator();
|
||||||
|
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
|
|
|
@ -27,7 +27,7 @@ abstract class BaseValueTransformer extends Configurable implements ValueTransfo
|
||||||
*/
|
*/
|
||||||
public function __construct(array $options = array())
|
public function __construct(array $options = array())
|
||||||
{
|
{
|
||||||
$this->locale = \Locale::getDefault();
|
$this->locale = class_exists('\Locale', false) ? \Locale::getDefault() : 'en';
|
||||||
|
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace Symfony\Tests\Components\Form;
|
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)
|
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
|
||||||
{
|
{
|
||||||
|
|
|
@ -634,7 +634,7 @@ class FieldGroupTest extends \PHPUnit_Framework_TestCase
|
||||||
$group->add($field);
|
$group->add($field);
|
||||||
$group->setLocale('de_DE');
|
$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()
|
public function testTranslatorIsPassedToField_SetBeforeAddingTheField()
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Symfony\Tests\Components\Form;
|
namespace Symfony\Tests\Components\Form;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\IntegerField;
|
use Symfony\Components\Form\IntegerField;
|
||||||
|
|
||||||
class IntegerFieldTest extends \PHPUnit_Framework_TestCase
|
class IntegerFieldTest extends LocalizedTestCase
|
||||||
{
|
{
|
||||||
public function testBindCastsToInteger()
|
public function testBindCastsToInteger()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Symfony\Tests\Components\Form;
|
namespace Symfony\Tests\Components\Form;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\MoneyField;
|
use Symfony\Components\Form\MoneyField;
|
||||||
|
|
||||||
class MoneyFieldTest extends \PHPUnit_Framework_TestCase
|
class MoneyFieldTest extends LocalizedTestCase
|
||||||
{
|
{
|
||||||
public function testRenderWithoutCurrency()
|
public function testRenderWithoutCurrency()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Symfony\Tests\Components\Form;
|
namespace Symfony\Tests\Components\Form;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\NumberField;
|
use Symfony\Components\Form\NumberField;
|
||||||
|
|
||||||
class NumberFieldTest extends \PHPUnit_Framework_TestCase
|
class NumberFieldTest extends LocalizedTestCase
|
||||||
{
|
{
|
||||||
public function testRender()
|
public function testRender()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Symfony\Tests\Components\Form;
|
namespace Symfony\Tests\Components\Form;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\PercentField;
|
use Symfony\Components\Form\PercentField;
|
||||||
|
|
||||||
class PercentFieldTest extends \PHPUnit_Framework_TestCase
|
class PercentFieldTest extends LocalizedTestCase
|
||||||
{
|
{
|
||||||
public function testRender()
|
public function testRender()
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,8 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
|
$this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
|
||||||
$this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
|
$this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
namespace Symfony\Tests\Components\Form\ValueTransformer;
|
namespace Symfony\Tests\Components\Form\ValueTransformer;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\ValueTransformer\NumberToLocalizedStringTransformer;
|
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()
|
public function testTransform()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
namespace Symfony\Tests\Components\Form\ValueTransformer;
|
namespace Symfony\Tests\Components\Form\ValueTransformer;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../LocalizedTestCase.php';
|
||||||
|
|
||||||
use Symfony\Components\Form\ValueTransformer\PercentToLocalizedStringTransformer;
|
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()
|
public function testTransform()
|
||||||
{
|
{
|
||||||
|
|
Reference in New Issue