From faeecf81ce1fa64fdab3fcdf61a80f86be0f534a Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Mon, 3 Dec 2012 15:24:31 +0100 Subject: [PATCH 1/6] Fix namespace of Validator and BrowserKit Tests --- src/Symfony/Component/BrowserKit/Tests/ClientTest.php | 2 +- src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php | 2 +- src/Symfony/Component/BrowserKit/Tests/CookieTest.php | 2 +- src/Symfony/Component/BrowserKit/Tests/HistoryTest.php | 2 +- src/Symfony/Component/BrowserKit/Tests/RequestTest.php | 2 +- src/Symfony/Component/BrowserKit/Tests/ResponseTest.php | 2 +- src/Symfony/Component/Validator/Tests/Constraints/AllTest.php | 2 +- .../Component/Validator/Tests/Constraints/CollectionTest.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 91d52df637..e03b73cf0b 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\History; diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 0c077d3723..df5cc777d4 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\Cookie; diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 2db3ac6f24..13e343a901 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\Cookie; diff --git a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php index 6794f31dde..882b730ef4 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\Request; diff --git a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php index c567faddee..b75b5fb5c0 100644 --- a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\Request; diff --git a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php index 1e8c638a3b..878752c75e 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Tests\BrowserKit; +namespace Symfony\Component\BrowserKit\Tests; use Symfony\Component\BrowserKit\Response; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php index 85b1283f2c..e2db52f60d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Allator\Tests\Constraints; +namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Valid; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php index 184d254342..e2998689ac 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Collectionator\Tests\Constraints; +namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\Collection\Required; From 2ed30e702fe4beb44b153006f9f0160fbc621551 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Fri, 30 Nov 2012 00:55:51 +0100 Subject: [PATCH 2/6] Fixed DefaultValue for session.auto_start in NodeDefinition This is just for consistency with the node type (Boolean) --- .../FrameworkBundle/DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index e5c1387cfc..8d9b94cfff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -192,7 +192,7 @@ class Configuration implements ConfigurationInterface ->children() ->booleanNode('auto_start') ->info('DEPRECATED! Session starts on demand') - ->defaultNull() + ->defaultFalse() ->beforeNormalization() ->ifTrue(function($v) { return null !== $v; }) ->then(function($v) { From d03281b400e8287803dcf3f804bf7b4209af7d68 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Tue, 4 Dec 2012 01:06:59 +0100 Subject: [PATCH 3/6] [Security] Move DigestDataTest.php inside the Security component --- .../Component/Security/Tests}/Http/Firewall/DigestDataTest.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {tests/Symfony/Tests/Component/Security => src/Symfony/Component/Security/Tests}/Http/Firewall/DigestDataTest.php (100%) diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php similarity index 100% rename from tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php rename to src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php From acf1f866116dc30837fdb2ed671f7929a3d559f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 4 Dec 2012 11:28:54 +0100 Subject: [PATCH 4/6] [TwigBundle] Fixed tests --- .../DependencyInjection/TwigExtensionTest.php | 16 ++-- .../TwigBundle/Tests/TwigEngineTest.php | 92 ------------------- 2 files changed, 9 insertions(+), 99 deletions(-) delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/TwigEngineTest.php diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 17fc9bcb35..f7ba5e987f 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -59,15 +59,17 @@ class TwigExtensionTest extends TestCase // Globals $calls = $container->getDefinition('twig')->getMethodCalls(); - $this->assertEquals('foo', $calls[0][1][0], '->load() registers services as Twig globals'); - $this->assertEquals(new Reference('bar'), $calls[0][1][1], '->load() registers services as Twig globals'); - $this->assertEquals('pi', $calls[1][1][0], '->load() registers variables as Twig globals'); - $this->assertEquals(3.14, $calls[1][1][1], '->load() registers variables as Twig globals'); + $this->assertEquals('app', $calls[0][1][0]); + $this->assertEquals(new Reference('templating.globals'), $calls[0][1][1]); + $this->assertEquals('foo', $calls[1][1][0], '->load() registers services as Twig globals'); + $this->assertEquals(new Reference('bar'), $calls[1][1][1], '->load() registers services as Twig globals'); + $this->assertEquals('pi', $calls[2][1][0], '->load() registers variables as Twig globals'); + $this->assertEquals(3.14, $calls[2][1][1], '->load() registers variables as Twig globals'); // Yaml and Php specific configs if (in_array($format, array('yml', 'php'))) { - $this->assertEquals('bad', $calls[2][1][0], '->load() registers variables as Twig globals'); - $this->assertEquals(array('key' => 'foo'), $calls[2][1][1], '->load() registers variables as Twig globals'); + $this->assertEquals('bad', $calls[3][1][0], '->load() registers variables as Twig globals'); + $this->assertEquals(array('key' => 'foo'), $calls[3][1][1], '->load() registers variables as Twig globals'); } // Twig options @@ -101,7 +103,7 @@ class TwigExtensionTest extends TestCase $calls = $container->getDefinition('twig')->getMethodCalls(); - foreach ($calls as $call) { + foreach (array_slice($calls, 1) as $call) { list($name, $value) = each($globals); $this->assertEquals($name, $call[1][0]); $this->assertSame($value, $call[1][1]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TwigEngineTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TwigEngineTest.php deleted file mode 100644 index 23889abd7a..0000000000 --- a/src/Symfony/Bundle/TwigBundle/Tests/TwigEngineTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests; - -use Symfony\Bundle\TwigBundle\TwigEngine; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session; -use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage; -use Symfony\Component\Templating\TemplateNameParser; -use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; - -class TwigEngineTest extends TestCase -{ - public function testEvaluateAddsAppGlobal() - { - $environment = $this->getTwigEnvironment(); - $container = $this->getContainer(); - $engine = new TwigEngine($environment, new TemplateNameParser(), $app = new GlobalVariables($container)); - - $template = $this->getMock('\Twig_TemplateInterface'); - - $environment->expects($this->once()) - ->method('loadTemplate') - ->will($this->returnValue($template)); - - $engine->render('name'); - - $request = $container->get('request'); - $globals = $environment->getGlobals(); - $this->assertSame($app, $globals['app']); - } - - public function testEvaluateWithoutAvailableRequest() - { - $environment = $this->getTwigEnvironment(); - $container = new Container(); - $engine = new TwigEngine($environment, new TemplateNameParser(), new GlobalVariables($container)); - - $template = $this->getMock('\Twig_TemplateInterface'); - - $environment->expects($this->once()) - ->method('loadTemplate') - ->will($this->returnValue($template)); - - $container->set('request', null); - - $engine->render('name'); - - $globals = $environment->getGlobals(); - $this->assertEmpty($globals['app']->getRequest()); - } - - /** - * Creates a Container with a Session-containing Request service. - * - * @return Container - */ - protected function getContainer() - { - $container = new Container(); - $request = new Request(); - $session = new Session(new ArraySessionStorage()); - - $request->setSession($session); - $container->set('request', $request); - - return $container; - } - - /** - * Creates a mock Twig_Environment object. - * - * @return \Twig_Environment - */ - protected function getTwigEnvironment() - { - return $this - ->getMockBuilder('\Twig_Environment') - ->setMethods(array('loadTemplate')) - ->getMock(); - } -} From 500cc3c4d7edc4222cb169dd353d6487fecd0855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 4 Dec 2012 11:28:17 +0100 Subject: [PATCH 5/6] [Config] Fixed tests on Windows --- .../Tests/Component/Config/Resource/DirectoryResourceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Symfony/Tests/Component/Config/Resource/DirectoryResourceTest.php b/tests/Symfony/Tests/Component/Config/Resource/DirectoryResourceTest.php index 8e2abaeed1..e8175e7786 100644 --- a/tests/Symfony/Tests/Component/Config/Resource/DirectoryResourceTest.php +++ b/tests/Symfony/Tests/Component/Config/Resource/DirectoryResourceTest.php @@ -38,7 +38,7 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase { $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $path) { - if (preg_match('#/\.\.?$#', $path->__toString())) { + if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) { continue; } if ($path->isDir()) { From 5fe58bffc5ea8bb4853a53c2c9d345801b9af941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Wed, 5 Dec 2012 13:49:46 +0100 Subject: [PATCH 6/6] [Locale] fixed tests --- phpunit.xml.dist | 4 ++ ...teTimeToLocalizedStringTransformerTest.php | 8 ++- .../Locale/Stub/StubIntlDateFormatterTest.php | 62 ++++++++++++------- .../Locale/Stub/StubNumberFormatterTest.php | 43 +++++++------ .../Tests/Component/Locale/TestCase.php | 8 +++ 5 files changed, 82 insertions(+), 43 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 147b39be32..c6628506c9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,6 +11,10 @@ syntaxCheck="false" bootstrap="tests/bootstrap.php" > + + + + ./tests/Symfony/ diff --git a/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index cf1a79321b..c0ae5ea143 100644 --- a/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -91,7 +91,9 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase { $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::LONG); - $this->assertEquals('03.02.2010 04:05:06 GMT+00:00', $transformer->transform($this->dateTime)); + $expected = $this->isLowerThanIcuVersion('4.8') ? '03.02.2010 04:05:06 GMT+00:00' : '03.02.2010 04:05:06 GMT'; + + $this->assertEquals($expected, $transformer->transform($this->dateTime)); } public function testTransformFullTime() @@ -102,7 +104,9 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); - $this->assertEquals('03.02.2010 04:05:06 GMT+00:00', $transformer->transform($this->dateTime)); + $expected = $this->isLowerThanIcuVersion('4.8') ? '03.02.2010 04:05:06 GMT+00:00' : '03.02.2010 04:05:06 GMT'; + + $this->assertEquals($expected, $transformer->transform($this->dateTime)); } public function testTransformToDifferentLocale() diff --git a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php index b3db625221..c99120998d 100644 --- a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php +++ b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php @@ -123,10 +123,8 @@ class StubIntlDateFormatterTest extends LocaleTestCase $formatData = array( /* general */ array('y-M-d', 0, '1970-1-1'), - array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT+00:00'), array("EEE, MMM d, ''yy", 0, "Thu, Jan 1, '70"), array('h:mm a', 0, '12:00 AM'), - array('K:mm a, z', 0, '0:00 AM, GMT+00:00'), array('yyyyy.MMMM.dd hh:mm aaa', 0, '01970.January.01 12:00 AM'), /* escaping */ @@ -287,26 +285,36 @@ class StubIntlDateFormatterTest extends LocaleTestCase array('s', 3601, '1'), array('s', 3630, '30'), array('s', 43200, '0'), // 12 hours - - /* timezone */ - array('z', 0, 'GMT+00:00'), - array('zz', 0, 'GMT+00:00'), - array('zzz', 0, 'GMT+00:00'), - array('zzzz', 0, 'GMT+00:00'), - array('zzzzz', 0, 'GMT+00:00'), ); + // Timezone + if (!$this->isIntlExtensionLoaded() || $this->isLowerThanIcuVersion('4.8')) { + // general + $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT+00:00'); + $formatData[] = array('K:mm a, z', 0, '0:00 AM, GMT+00:00'); + + // timezone + $formatData[] = array('z', 0, 'GMT+00:00'); + $formatData[] = array('zz', 0, 'GMT+00:00'); + $formatData[] = array('zzz', 0, 'GMT+00:00'); + $formatData[] = array('zzzz', 0, 'GMT+00:00'); + $formatData[] = array('zzzzz', 0, 'GMT+00:00'); + } + // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances if ($this->isGreaterOrEqualThanPhpVersion('5.3.4')) { $dateTime = new \DateTime('@0'); /* general, DateTime */ $formatData[] = array('y-M-d', $dateTime, '1970-1-1'); - $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT+00:00'); $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"); $formatData[] = array('h:mm a', $dateTime, '12:00 AM'); - $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT+00:00'); $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'); + + if (!$this->isIntlExtensionLoaded() || $this->isLowerThanIcuVersion('4.8')) { + $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT+00:00'); + $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT+00:00'); + } } return $formatData; @@ -430,7 +438,9 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter('zzzz'); $formatter->setTimeZoneId('Pacific/Fiji'); - $this->assertEquals('Fiji Time', $formatter->format(0)); + + $expected = $this->isGreaterOrEqualThanIcuVersion('49') ? 'Fiji Standard Time' : 'Fiji Time'; + $this->assertEquals($expected, $formatter->format(0)); } public function testFormatWithGmtTimezoneStub() @@ -464,7 +474,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $this->skipIfICUVersionIsTooOld(); - $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); + $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC'); $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals( @@ -493,7 +503,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase } /** - * It seems IntlDateFormatter caches the timezone id when not explicitely set via constructor or by the + * It seems IntlDateFormatter caches the timezone id when not explicitly set via constructor or by the * setTimeZoneId() method. Since testFormatWithDefaultTimezoneIntl() runs using the default environment * time zone, this test would use it too if not running in a separated process. * @@ -561,17 +571,21 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function dateAndTimeTypeProvider() { - return array( + $data = array( array(0, StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE, 'Thursday, January 1, 1970'), array(0, StubIntlDateFormatter::LONG, StubIntlDateFormatter::NONE, 'January 1, 1970'), array(0, StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::NONE, 'Jan 1, 1970'), array(0, StubIntlDateFormatter::SHORT, StubIntlDateFormatter::NONE, '1/1/70'), - - array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT+00:00'), - array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT+00:00'), array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::MEDIUM, '12:00:00 AM'), array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::SHORT, '12:00 AM'), ); + + if (!$this->isIntlExtensionLoaded() || $this->isLowerThanIcuVersion('4.8')) { + $data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT+00:00'); + $data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT+00:00'); + } + + return $data; } public function testGetCalendar() @@ -847,10 +861,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function parseErrorProvider() { - return array( - array('y-M-d', '1970/1/1'), - array('yy-M-d', '70/1/1'), - + $data = array( // 1 char month array('y-MMMMM-d', '1970-J-1'), array('y-MMMMM-d', '1970-S-1'), @@ -859,6 +870,13 @@ class StubIntlDateFormatterTest extends LocaleTestCase array('y-LLLLL-d', '1970-J-1'), array('y-LLLLL-d', '1970-S-1'), ); + + if (!$this->isIntlExtensionLoaded() || $this->isLowerThanIcuVersion('4.8')) { + $data[] = array('y-M-d', '1970/1/1'); + $data[] = array('yy-M-d', '70/1/1'); + } + + return $data; } /** diff --git a/tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php b/tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php index bb9fc85991..7fc2402c3d 100644 --- a/tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php +++ b/tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php @@ -142,19 +142,11 @@ class StubNumberFormatterTest extends LocaleTestCase public function formatCurrencyWithCurrencyStyleProvider() { - return array( + $data = array( array(100, 'ALL', 'ALL100'), array(-100, 'ALL', '(ALL100)'), array(1000.12, 'ALL', 'ALL1,000'), - array(100, 'BRL', 'R$100.00'), - array(-100, 'BRL', '(R$100.00)'), - array(1000.12, 'BRL', 'R$1,000.12'), - - array(100, 'CRC', '₡100'), - array(-100, 'CRC', '(₡100)'), - array(1000.12, 'CRC', '₡1,000'), - array(100, 'JPY', '¥100'), array(-100, 'JPY', '(¥100)'), array(1000.12, 'JPY', '¥1,000'), @@ -162,16 +154,29 @@ class StubNumberFormatterTest extends LocaleTestCase array(100, 'EUR', '€100.00'), array(-100, 'EUR', '(€100.00)'), array(1000.12, 'EUR', '€1,000.12'), - - // Rounding checks - array(1000.121, 'BRL', 'R$1,000.12'), - array(1000.123, 'BRL', 'R$1,000.12'), - array(1000.125, 'BRL', 'R$1,000.12'), - array(1000.127, 'BRL', 'R$1,000.13'), - array(1000.129, 'BRL', 'R$1,000.13'), - array(11.50999, 'BRL', 'R$11.51'), - array(11.9999464, 'BRL', 'R$12.00') ); + + if (!$this->isIntlExtensionLoaded() || !$this->isSameAsIcuVersion('4.8')) { + // Rounding checks + $data[] = array(100, 'BRL', 'R$100.00'); + $data[] = array(-100, 'BRL', '(R$100.00)'); + $data[] = array(1000.12, 'BRL', 'R$1,000.12'); + $data[] = array(1000.121, 'BRL', 'R$1,000.12'); + $data[] = array(1000.123, 'BRL', 'R$1,000.12'); + $data[] = array(1000.125, 'BRL', 'R$1,000.12'); + $data[] = array(1000.127, 'BRL', 'R$1,000.13'); + $data[] = array(1000.129, 'BRL', 'R$1,000.13'); + $data[] = array(11.50999, 'BRL', 'R$11.51'); + $data[] = array(11.9999464, 'BRL', 'R$12.00'); + } + + if (!$this->isIntlExtensionLoaded() || $this->isLowerThanIcuVersion('4.8')) { + $data[] = array(100, 'CRC', '₡100'); + $data[] = array(-100, 'CRC', '(₡100)'); + $data[] = array(1000.12, 'CRC', '₡1,000'); + } + + return $data; } /** @@ -180,7 +185,7 @@ class StubNumberFormatterTest extends LocaleTestCase public function testFormatCurrencyWithCurrencyStyleSwissRoundingStub($value, $currency, $symbol, $expected) { $formatter = $this->getStubFormatterWithCurrencyStyle(); - $this->assertEquals(sprintf($expected, 'CHF'), $formatter->formatCurrency($value, $currency)); + $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } /** diff --git a/tests/Symfony/Tests/Component/Locale/TestCase.php b/tests/Symfony/Tests/Component/Locale/TestCase.php index 8df87e447b..3ee1c60449 100644 --- a/tests/Symfony/Tests/Component/Locale/TestCase.php +++ b/tests/Symfony/Tests/Component/Locale/TestCase.php @@ -71,6 +71,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase return $icuVersion >= $version; } + protected function isSameAsIcuVersion($version) + { + $version = $this->normalizeIcuVersion($version); + $icuVersion = $this->normalizeIcuVersion($this->getIntlExtensionIcuVersion()); + + return $icuVersion === $version; + } + protected function isLowerThanIcuVersion($version) { $version = $this->normalizeIcuVersion($version);