From e3e5f3d661ba8c223e64b88412f3e2f6d70bb5e0 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 9 Jun 2015 23:44:30 +0200 Subject: [PATCH 1/3] [2.3] Fix tests on Windows --- .../Bridge/Twig/Tests/Translation/TwigExtractorTest.php | 4 ++-- .../FrameworkBundle/Tests/Command/RouterDebugCommandTest.php | 4 ++-- .../FrameworkBundle/Tests/Command/RouterMatchCommandTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 92c6015b5b..51e96f0ef9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -73,8 +73,8 @@ class TwigExtractorTest extends TestCase } /** - * @expectedException \Twig_Error - * @expectedExceptionMessage Unclosed "block" in "extractor/syntax_error.twig" at line 1 + * @expectedException \Twig_Error + * @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/ */ public function testExtractSyntaxError() { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php index bf5e183caa..86c2c2a003 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php @@ -22,7 +22,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase public function testDebugAllRoutes() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => null)); + $ret = $tester->execute(array('name' => null), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('[router] Current routes', $tester->getDisplay()); @@ -31,7 +31,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase public function testDebugSingleRoute() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'foo')); + $ret = $tester->execute(array('name' => 'foo'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('[router] Route "foo"', $tester->getDisplay()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php index 918ba02f6d..0244276696 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php @@ -24,7 +24,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase public function testWithMatchPath() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('path_info' => '/foo', 'foo')); + $ret = $tester->execute(array('path_info' => '/foo', 'foo'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('[router] Route "foo"', $tester->getDisplay()); @@ -33,7 +33,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase public function testWithNotMatchPath() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('path_info' => '/test', 'foo')); + $ret = $tester->execute(array('path_info' => '/test', 'foo'), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of failure'); $this->assertContains('None of the routes match the path "/test"', $tester->getDisplay()); From 786b8a664eb1abcd91de4df8459785e82646af00 Mon Sep 17 00:00:00 2001 From: azine Date: Sat, 6 Jun 2015 18:39:32 +0200 Subject: [PATCH 2/3] Allow new lines in Messages translated with transchoice() (replacement for #14867) --- .../Component/Translation/MessageSelector.php | 2 +- .../Translation/Tests/MessageSelectorTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/MessageSelector.php b/src/Symfony/Component/Translation/MessageSelector.php index eadd09c978..ff0f9f9d65 100644 --- a/src/Symfony/Component/Translation/MessageSelector.php +++ b/src/Symfony/Component/Translation/MessageSelector.php @@ -57,7 +57,7 @@ class MessageSelector foreach ($parts as $part) { $part = trim($part); - if (preg_match('/^(?P'.Interval::getIntervalRegexp().')\s*(?P.*?)$/x', $part, $matches)) { + if (preg_match('/^(?P'.Interval::getIntervalRegexp().')\s*(?P.*?)$/xs', $part, $matches)) { $explicitRules[$matches['interval']] = $matches['message']; } elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) { $standardRules[] = $matches[1]; diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index d5a4f3e3d5..48c30b3a14 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -93,6 +93,38 @@ class MessageSelectorTest extends \PHPUnit_Framework_TestCase array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0), array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0), array('There are no apples', '{0.0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0), + + // Test texts with new-lines + // with double-quotes and \n in id & double-quotes and actual newlines in text + array("This is a text with a\n new-line in it. Selector = 0.", "{0}This is a text with a + new-line in it. Selector = 0.|{1}This is a text with a + new-line in it. Selector = 1.|[1,Inf]This is a text with a + new-line in it. Selector > 1.", 0), + // with double-quotes and \n in id and single-quotes and actual newlines in text + array("This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a + new-line in it. Selector = 0.|{1}This is a text with a + new-line in it. Selector = 1.|[1,Inf]This is a text with a + new-line in it. Selector > 1.', 1), + array("This is a text with a\n new-line in it. Selector > 1.", '{0}This is a text with a + new-line in it. Selector = 0.|{1}This is a text with a + new-line in it. Selector = 1.|[1,Inf]This is a text with a + new-line in it. Selector > 1.', 5), + // with double-quotes and id split accros lines + array("This is a text with a + new-line in it. Selector = 1.", '{0}This is a text with a + new-line in it. Selector = 0.|{1}This is a text with a + new-line in it. Selector = 1.|[1,Inf]This is a text with a + new-line in it. Selector > 1.', 1), + // with single-quotes and id split accros lines + array('This is a text with a + new-line in it. Selector > 1.', '{0}This is a text with a + new-line in it. Selector = 0.|{1}This is a text with a + new-line in it. Selector = 1.|[1,Inf]This is a text with a + new-line in it. Selector > 1.', 5), + // with single-quotes and \n in text + array('This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0), + // with double-quotes and id split accros lines + array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1), ); } } From 009efb8dec48b26273be755253c38edda31e624b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 Jun 2015 15:53:10 +0200 Subject: [PATCH 3/3] fixed CS --- .../Component/Translation/Tests/MessageSelectorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index 48c30b3a14..f89bed16d5 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -96,10 +96,10 @@ class MessageSelectorTest extends \PHPUnit_Framework_TestCase // Test texts with new-lines // with double-quotes and \n in id & double-quotes and actual newlines in text - array("This is a text with a\n new-line in it. Selector = 0.", "{0}This is a text with a + array("This is a text with a\n new-line in it. Selector = 0.", '{0}This is a text with a new-line in it. Selector = 0.|{1}This is a text with a new-line in it. Selector = 1.|[1,Inf]This is a text with a - new-line in it. Selector > 1.", 0), + new-line in it. Selector > 1.', 0), // with double-quotes and \n in id and single-quotes and actual newlines in text array("This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a new-line in it. Selector = 0.|{1}This is a text with a @@ -110,8 +110,8 @@ class MessageSelectorTest extends \PHPUnit_Framework_TestCase new-line in it. Selector = 1.|[1,Inf]This is a text with a new-line in it. Selector > 1.', 5), // with double-quotes and id split accros lines - array("This is a text with a - new-line in it. Selector = 1.", '{0}This is a text with a + array('This is a text with a + new-line in it. Selector = 1.', '{0}This is a text with a new-line in it. Selector = 0.|{1}This is a text with a new-line in it. Selector = 1.|[1,Inf]This is a text with a new-line in it. Selector > 1.', 1),