Skip to content
This repository
Browse code

Merge branch '2.2'

* 2.2:
  #7106 - fix for ZTS builds
  Added '@@' escaping strategy for YamlFileLoader and YamlDumper
  [Yaml] fixed bugs with folded scalar parsing
  [Form] made DefaultCsrfProvider using session_status() when available
  Added unit tests to Dumper
  Update .travis.yml (closes #7355)
  [HttpFoudantion] fixed Request::getPreferredLanguage()
  Revert "merged branch jfsimon/issue-6928 (PR #7378)"
  Routing issue with installation in a sub-directory ref: #7129
  • Loading branch information...
commit 77ec79975104cb152725a64699906841a58dbfe2 2 parents a045925 + 03fc97d
Fabien Potencier authored March 23, 2013
1  .travis.yml
@@ -12,6 +12,7 @@ matrix:
12 12
 
13 13
 before_script:
14 14
     - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
  15
+    - echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
15 16
     - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
16 17
     - php src/Symfony/Component/Locale/Resources/data/build-data.php
17 18
     - export USE_INTL_ICU_DATA_VERSION=1
2  src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -260,7 +260,7 @@ private function prepareParameters($parameters, $escape = true)
260 260
         foreach ($parameters as $key => $value) {
261 261
             if (is_array($value)) {
262 262
                 $value = $this->prepareParameters($value, $escape);
263  
-            } elseif ($value instanceof Reference) {
  263
+            } elseif ($value instanceof Reference || is_string($value) && 0 === strpos($value, '@')) {
264 264
                 $value = '@'.$value;
265 265
             }
266 266
 
9  src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -290,7 +290,10 @@ private function resolveServices($value)
290 290
         if (is_array($value)) {
291 291
             $value = array_map(array($this, 'resolveServices'), $value);
292 292
         } elseif (is_string($value) &&  0 === strpos($value, '@')) {
293  
-            if (0 === strpos($value, '@?')) {
  293
+            if (0 === strpos($value, '@@')) {
  294
+                $value = substr($value, 1);
  295
+                $invalidBehavior = null;
  296
+            } elseif (0 === strpos($value, '@?')) {
294 297
                 $value = substr($value, 2);
295 298
                 $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
296 299
             } else {
@@ -305,7 +308,9 @@ private function resolveServices($value)
305 308
                 $strict = true;
306 309
             }
307 310
 
308  
-            $value = new Reference($value, $invalidBehavior, $strict);
  311
+            if (null !== $invalidBehavior) {
  312
+                $value = new Reference($value, $invalidBehavior, $strict);
  313
+            }
309 314
         }
310 315
 
311 316
         return $value;
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php
@@ -7,6 +7,7 @@
7 7
     'FOO'    => '%baz%',
8 8
     'baz'    => 'bar',
9 9
     'bar'    => 'foo is %%foo bar',
  10
+    'escape' => '@escapeme',
10 11
     'values' => array(true, false, null, 0, 1000.3, 'true', 'false', 'null'),
11 12
 )));
12 13
 
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
@@ -37,6 +37,7 @@ protected function getDefaultParameters()
37 37
             'foo' => '%baz%',
38 38
             'baz' => 'bar',
39 39
             'bar' => 'foo is %%foo bar',
  40
+            'escape' => '@escapeme',
40 41
             'values' => array(
41 42
                 0 => true,
42 43
                 1 => false,
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml
@@ -7,6 +7,7 @@
7 7
     <parameter key="foo">%baz%</parameter>
8 8
     <parameter key="baz">bar</parameter>
9 9
     <parameter key="bar">foo is %%foo bar</parameter>
  10
+    <parameter key="escape">@escapeme</parameter>
10 11
     <parameter key="values" type="collection">
11 12
       <parameter>true</parameter>
12 13
       <parameter>false</parameter>
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml
@@ -6,6 +6,7 @@ parameters:
6 6
         - 0
7 7
         - 1000.3
8 8
     bar: foo
  9
+    escape: @@escapeme
9 10
     foo_bar: @foo_bar
10 11
     MixedCase:
11 12
         MixedCaseKey: value
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml
@@ -2,5 +2,6 @@ parameters:
2 2
     foo: '%baz%'
3 3
     baz: bar
4 4
     bar: 'foo is %%foo bar'
  5
+    escape: '@@escapeme'
5 6
     values: [true, false, null, 0, 1000.3, 'true', 'false', 'null']
6 7
 
4  src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -84,7 +84,7 @@ public function testLoadParameters()
84 84
         $container = new ContainerBuilder();
85 85
         $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
86 86
         $loader->load('services2.yml');
87  
-        $this->assertEquals(array('foo' => 'bar', 'mixedcase' => array('MixedCaseKey' => 'value'), 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase');
  87
+        $this->assertEquals(array('foo' => 'bar', 'mixedcase' => array('MixedCaseKey' => 'value'), 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar')), $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase');
88 88
     }
89 89
 
90 90
     public function testLoadImports()
@@ -99,7 +99,7 @@ public function testLoadImports()
99 99
         $loader->load('services4.yml');
100 100
 
101 101
         $actual = $container->getParameterBag()->all();
102  
-        $expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'imported_from_ini' => true, 'imported_from_xml' => true);
  102
+        $expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'imported_from_ini' => true, 'imported_from_xml' => true);
103 103
         $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
104 104
 
105 105
         // Bad import throws no exception due to ignore_errors value.
6  src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php
@@ -65,7 +65,11 @@ public function isCsrfTokenValid($intention, $token)
65 65
      */
66 66
     protected function getSessionId()
67 67
     {
68  
-        if (!session_id()) {
  68
+        if (version_compare(PHP_VERSION, '5.4', '>=')) {
  69
+            if (PHP_SESSION_NONE === session_status()) {
  70
+                session_start();
  71
+            }
  72
+        } elseif (!session_id()) {
69 73
             session_start();
70 74
         }
71 75
 
25  src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
@@ -22,7 +22,8 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase
22 22
 
23 23
     public static function setUpBeforeClass()
24 24
     {
25  
-        @session_start();
  25
+        ini_set('session.save_handler', 'files');
  26
+        ini_set('session.save_path', sys_get_temp_dir());
26 27
     }
27 28
 
28 29
     protected function setUp()
@@ -37,13 +38,33 @@ protected function tearDown()
37 38
 
38 39
     public function testGenerateCsrfToken()
39 40
     {
  41
+        session_start();
  42
+
  43
+        $token = $this->provider->generateCsrfToken('foo');
  44
+
  45
+        $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
  46
+    }
  47
+
  48
+    public function testGenerateCsrfTokenOnUnstartedSession()
  49
+    {
  50
+        session_id('touti');
  51
+
  52
+        if (!version_compare(PHP_VERSION, '5.4', '>=')) {
  53
+            $this->markTestSkipped('This test requires PHP >= 5.4');
  54
+        }
  55
+
  56
+        $this->assertSame(PHP_SESSION_NONE, session_status());
  57
+
40 58
         $token = $this->provider->generateCsrfToken('foo');
41 59
 
42 60
         $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
  61
+        $this->assertSame(PHP_SESSION_ACTIVE, session_status());
43 62
     }
44 63
 
45 64
     public function testIsCsrfTokenValidSucceeds()
46 65
     {
  66
+        session_start();
  67
+
47 68
         $token = sha1('SECRET'.'foo'.session_id());
48 69
 
49 70
         $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token));
@@ -51,6 +72,8 @@ public function testIsCsrfTokenValidSucceeds()
51 72
 
52 73
     public function testIsCsrfTokenValidFails()
53 74
     {
  75
+        session_start();
  76
+
54 77
         $token = sha1('SECRET'.'bar'.session_id());
55 78
 
56 79
         $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token));
22  src/Symfony/Component/HttpFoundation/Request.php
@@ -1345,7 +1345,18 @@ public function getPreferredLanguage(array $locales = null)
1345 1345
             return $locales[0];
1346 1346
         }
1347 1347
 
1348  
-        $preferredLanguages = array_values(array_intersect($preferredLanguages, $locales));
  1348
+        $extendedPreferredLanguages = array();
  1349
+        foreach ($preferredLanguages as $language) {
  1350
+            $extendedPreferredLanguages[] = $language;
  1351
+            if (false !== $position = strpos($language, '_')) {
  1352
+                $superLanguage = substr($language, 0, $position);
  1353
+                if (!in_array($superLanguage, $preferredLanguages)) {
  1354
+                    $extendedPreferredLanguages[] = $superLanguage;
  1355
+                }
  1356
+            }
  1357
+        }
  1358
+
  1359
+        $preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
1349 1360
 
1350 1361
         return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
1351 1362
     }
@@ -1379,11 +1390,6 @@ public function getLanguages()
1379 1390
                     for ($i = 0, $max = count($codes); $i < $max; $i++) {
1380 1391
                         if ($i == 0) {
1381 1392
                             $lang = strtolower($codes[0]);
1382  
-                            // First segment of compound language codes
1383  
-                            // is added to supported languages list
1384  
-                            if (!in_array($lang, $this->languages)) {
1385  
-                                $this->languages[] = $lang;
1386  
-                            }
1387 1393
                         } else {
1388 1394
                             $lang .= '_'.strtoupper($codes[$i]);
1389 1395
                         }
@@ -1391,9 +1397,7 @@ public function getLanguages()
1391 1397
                 }
1392 1398
             }
1393 1399
 
1394  
-            if (!in_array($lang, $this->languages)) {
1395  
-                $this->languages[] = $lang;
1396  
-            }
  1400
+            $this->languages[] = $lang;
1397 1401
         }
1398 1402
 
1399 1403
         return $this->languages;
16  src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
@@ -1013,6 +1013,14 @@ public function testGetPreferredLanguage()
1013 1013
         $request = new Request();
1014 1014
         $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
1015 1015
         $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
  1016
+
  1017
+        $request = new Request();
  1018
+        $request->headers->set('Accept-language', 'zh, en-us; q=0.8');
  1019
+        $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
  1020
+
  1021
+        $request = new Request();
  1022
+        $request->headers->set('Accept-language', 'zh, en-us; q=0.8, fr-fr; q=0.6, fr; q=0.5');
  1023
+        $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
1016 1024
     }
1017 1025
 
1018 1026
     public function testIsXmlHttpRequest()
@@ -1083,8 +1091,8 @@ public function testGetLanguages()
1083 1091
 
1084 1092
         $request = new Request();
1085 1093
         $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
1086  
-        $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages());
1087  
-        $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages());
  1094
+        $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages());
  1095
+        $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages());
1088 1096
 
1089 1097
         $request = new Request();
1090 1098
         $request->headers->set('Accept-language', 'zh, en-us; q=0.6, en; q=0.8');
@@ -1101,10 +1109,6 @@ public function testGetLanguages()
1101 1109
         $request = new Request();
1102 1110
         $request->headers->set('Accept-language', 'zh, i-cherokee; q=0.6');
1103 1111
         $this->assertEquals(array('zh', 'cherokee'), $request->getLanguages());
1104  
-
1105  
-        $request = new Request();
1106  
-        $request->headers->set('Accept-language', 'en-us');
1107  
-        $this->assertEquals(array('en', 'en_US'), $request->getLanguages());
1108 1112
     }
1109 1113
 
1110 1114
     public function testGetRequestFormat()
7  src/Symfony/Component/Process/Process.php
@@ -131,8 +131,13 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
131 131
 
132 132
         $this->commandline = $commandline;
133 133
         $this->cwd = $cwd;
  134
+
134 135
         // on windows, if the cwd changed via chdir(), proc_open defaults to the dir where php was started
135  
-        if (null === $this->cwd && defined('PHP_WINDOWS_VERSION_BUILD')) {
  136
+        // on gnu/linux, PHP builds with --enable-maintainer-zts are also affected
  137
+        // @see : https://bugs.php.net/bug.php?id=51800
  138
+        // @see : https://bugs.php.net/bug.php?id=50524
  139
+
  140
+        if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
136 141
             $this->cwd = getcwd();
137 142
         }
138 143
         if (null !== $env) {
85  src/Symfony/Component/Yaml/Parser.php
@@ -414,64 +414,61 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
414 414
      */
415 415
     private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
416 416
     {
417  
-        $separator = '|' == $separator ? "\n" : ' ';
418  
-        $text = '';
419  
-
420 417
         $notEOF = $this->moveToNextLine();
421  
-
422  
-        while ($notEOF && $this->isCurrentLineBlank()) {
423  
-            $text .= "\n";
424  
-
425  
-            $notEOF = $this->moveToNextLine();
426  
-        }
427  
-
428 418
         if (!$notEOF) {
429 419
             return '';
430 420
         }
431 421
 
432  
-        if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#u', $this->currentLine, $matches)) {
433  
-            $this->moveToPreviousLine();
434  
-
435  
-            return '';
  422
+        // determine indentation if not specified
  423
+        if (0 === $indentation) {
  424
+            if (preg_match('/^ +/', $this->currentLine, $matches)) {
  425
+                $indentation = strlen($matches[0]);
  426
+            }
436 427
         }
437 428
 
438  
-        $textIndent = $matches['indent'];
439  
-        $previousIndent = 0;
440  
-
441  
-        $text .= $matches['text'].$separator;
442  
-        while ($this->currentLineNb + 1 < count($this->lines)) {
443  
-            $this->moveToNextLine();
444  
-
445  
-            if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#u', $this->currentLine, $matches)) {
446  
-                if (' ' == $separator && $previousIndent != $matches['indent']) {
447  
-                    $text = substr($text, 0, -1)."\n";
  429
+        $text = '';
  430
+        if ($indentation > 0) {
  431
+            $pattern = sprintf('/^ {%d}(.*)$/', $indentation);
  432
+
  433
+            $isCurrentLineBlank = $this->isCurrentLineBlank();
  434
+            while (
  435
+                $notEOF && (
  436
+                    $isCurrentLineBlank ||
  437
+                    preg_match($pattern, $this->currentLine, $matches)
  438
+                )
  439
+            ) {
  440
+                if ($isCurrentLineBlank) {
  441
+                    $text .= substr($this->currentLine, $indentation);
  442
+                } else {
  443
+                    $text .= $matches[1];
448 444
                 }
449  
-                $previousIndent = $matches['indent'];
450 445
 
451  
-                $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator);
452  
-            } elseif (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches)) {
453  
-                $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n";
454  
-            } else {
455  
-                $this->moveToPreviousLine();
456  
-
457  
-                break;
  446
+                // newline only if not EOF
  447
+                if ($notEOF = $this->moveToNextLine()) {
  448
+                    $text .= "\n";
  449
+                    $isCurrentLineBlank = $this->isCurrentLineBlank();
  450
+                }
458 451
             }
  452
+        } elseif ($notEOF) {
  453
+            $text .= "\n";
459 454
         }
460 455
 
461  
-        if (' ' == $separator) {
462  
-            // replace last separator by a newline
463  
-            $text = preg_replace('/ (\n*)$/', "\n$1", $text);
  456
+        if ($notEOF) {
  457
+            $this->moveToPreviousLine();
464 458
         }
465 459
 
466  
-        switch ($indicator) {
467  
-            case '':
468  
-                $text = preg_replace('#\n+$#s', "\n", $text);
469  
-                break;
470  
-            case '+':
471  
-                break;
472  
-            case '-':
473  
-                $text = preg_replace('#\n+$#s', '', $text);
474  
-                break;
  460
+        // replace all non-trailing single newlines with spaces in folded blocks
  461
+        if ('>' === $separator) {
  462
+            preg_match('/(\n*)$/', $text, $matches);
  463
+            $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
  464
+            $text .= $matches[1];
  465
+        }
  466
+
  467
+        // deal with trailing newlines as indicated
  468
+        if ('' === $indicator) {
  469
+            $text = preg_replace('/\n+$/s', "\n", $text);
  470
+        } elseif ('-' === $indicator) {
  471
+            $text = preg_replace('/\n+$/s', '', $text);
475 472
         }
476 473
 
477 474
         return $text;
72  src/Symfony/Component/Yaml/Tests/DumperTest.php
@@ -21,6 +21,21 @@ class DumperTest extends \PHPUnit_Framework_TestCase
21 21
     protected $dumper;
22 22
     protected $path;
23 23
 
  24
+    protected $array = array(
  25
+        '' => 'bar',
  26
+        'foo' => '#bar',
  27
+        'foo\'bar' => array(),
  28
+        'bar' => array(1, 'foo'),
  29
+        'foobar' => array(
  30
+            'foo' => 'bar',
  31
+            'bar' => array(1, 'foo'),
  32
+            'foobar' => array(
  33
+                'foo' => 'bar',
  34
+                'bar' => array(1, 'foo'),
  35
+            ),
  36
+        ),
  37
+    );
  38
+
24 39
     protected function setUp()
25 40
     {
26 41
         $this->parser = new Parser();
@@ -33,6 +48,33 @@ protected function tearDown()
33 48
         $this->parser = null;
34 49
         $this->dumper = null;
35 50
         $this->path = null;
  51
+        $this->array = null;
  52
+    }
  53
+
  54
+    public function testSetIndentation()
  55
+    {
  56
+        $this->dumper->setIndentation(7);
  57
+
  58
+$expected = <<<EOF
  59
+'': bar
  60
+foo: '#bar'
  61
+'foo''bar': {  }
  62
+bar:
  63
+       - 1
  64
+       - foo
  65
+foobar:
  66
+       foo: bar
  67
+       bar:
  68
+              - 1
  69
+              - foo
  70
+       foobar:
  71
+              foo: bar
  72
+              bar:
  73
+                     - 1
  74
+                     - foo
  75
+
  76
+EOF;
  77
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0));
36 78
     }
37 79
 
38 80
     public function testSpecifications()
@@ -63,27 +105,11 @@ public function testSpecifications()
63 105
 
64 106
     public function testInlineLevel()
65 107
     {
66  
-        // inline level
67  
-        $array = array(
68  
-            '' => 'bar',
69  
-            'foo' => '#bar',
70  
-            'foo\'bar' => array(),
71  
-            'bar' => array(1, 'foo'),
72  
-            'foobar' => array(
73  
-                'foo' => 'bar',
74  
-                'bar' => array(1, 'foo'),
75  
-                'foobar' => array(
76  
-                    'foo' => 'bar',
77  
-                    'bar' => array(1, 'foo'),
78  
-                ),
79  
-            ),
80  
-        );
81  
-
82 108
         $expected = <<<EOF
83 109
 { '': bar, foo: '#bar', 'foo''bar': {  }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
84 110
 EOF;
85  
-$this->assertEquals($expected, $this->dumper->dump($array, -10), '->dump() takes an inline level argument');
86  
-$this->assertEquals($expected, $this->dumper->dump($array, 0), '->dump() takes an inline level argument');
  111
+$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
  112
+$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
87 113
 
88 114
 $expected = <<<EOF
89 115
 '': bar
@@ -93,7 +119,7 @@ public function testInlineLevel()
93 119
 foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
94 120
 
95 121
 EOF;
96  
-        $this->assertEquals($expected, $this->dumper->dump($array, 1), '->dump() takes an inline level argument');
  122
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
97 123
 
98 124
         $expected = <<<EOF
99 125
 '': bar
@@ -108,7 +134,7 @@ public function testInlineLevel()
108 134
     foobar: { foo: bar, bar: [1, foo] }
109 135
 
110 136
 EOF;
111  
-        $this->assertEquals($expected, $this->dumper->dump($array, 2), '->dump() takes an inline level argument');
  137
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
112 138
 
113 139
         $expected = <<<EOF
114 140
 '': bar
@@ -127,7 +153,7 @@ public function testInlineLevel()
127 153
         bar: [1, foo]
128 154
 
129 155
 EOF;
130  
-        $this->assertEquals($expected, $this->dumper->dump($array, 3), '->dump() takes an inline level argument');
  156
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
131 157
 
132 158
         $expected = <<<EOF
133 159
 '': bar
@@ -148,8 +174,8 @@ public function testInlineLevel()
148 174
             - foo
149 175
 
150 176
 EOF;
151  
-        $this->assertEquals($expected, $this->dumper->dump($array, 4), '->dump() takes an inline level argument');
152  
-        $this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument');
  177
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
  178
+        $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
153 179
     }
154 180
 
155 181
     public function testObjectSupportEnabled()
116  src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -113,17 +113,33 @@ public function getBlockChompingTests()
113 113
 foo: |-
114 114
     one
115 115
     two
  116
+bar: |-
  117
+    one
  118
+    two
  119
+
  120
+EOF;
  121
+        $expected = array(
  122
+            'foo' => "one\ntwo",
  123
+            'bar' => "one\ntwo",
  124
+        );
  125
+        $tests['Literal block chomping strip with single trailing newline'] = array($expected, $yaml);
  126
+
  127
+        $yaml = <<<'EOF'
  128
+foo: |-
  129
+    one
  130
+    two
116 131
 
117 132
 bar: |-
118 133
     one
119 134
     two
120 135
 
  136
+
121 137
 EOF;
122 138
         $expected = array(
123 139
             'foo' => "one\ntwo",
124 140
             'bar' => "one\ntwo",
125 141
         );
126  
-        $tests['Literal block chomping strip with trailing newline'] = array($expected, $yaml);
  142
+        $tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
127 143
 
128 144
         $yaml = <<<'EOF'
129 145
 foo: |-
@@ -143,7 +159,6 @@ public function getBlockChompingTests()
143 159
 foo: |
144 160
     one
145 161
     two
146  
-
147 162
 bar: |
148 163
     one
149 164
     two
@@ -153,37 +168,70 @@ public function getBlockChompingTests()
153 168
             'foo' => "one\ntwo\n",
154 169
             'bar' => "one\ntwo\n",
155 170
         );
156  
-        $tests['Literal block chomping clip with trailing newline'] = array($expected, $yaml);
  171
+        $tests['Literal block chomping clip with single trailing newline'] = array($expected, $yaml);
157 172
 
158 173
         $yaml = <<<'EOF'
159 174
 foo: |
160 175
     one
161 176
     two
  177
+
162 178
 bar: |
163 179
     one
164 180
     two
  181
+
  182
+
165 183
 EOF;
166 184
         $expected = array(
167 185
             'foo' => "one\ntwo\n",
168 186
             'bar' => "one\ntwo\n",
169 187
         );
  188
+        $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
  189
+
  190
+        $yaml = <<<'EOF'
  191
+foo: |
  192
+    one
  193
+    two
  194
+bar: |
  195
+    one
  196
+    two
  197
+EOF;
  198
+        $expected = array(
  199
+            'foo' => "one\ntwo\n",
  200
+            'bar' => "one\ntwo",
  201
+        );
170 202
         $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml);
171 203
 
172 204
         $yaml = <<<'EOF'
173 205
 foo: |+
174 206
     one
175 207
     two
  208
+bar: |+
  209
+    one
  210
+    two
  211
+
  212
+EOF;
  213
+        $expected = array(
  214
+            'foo' => "one\ntwo\n",
  215
+            'bar' => "one\ntwo\n",
  216
+        );
  217
+        $tests['Literal block chomping keep with single trailing newline'] = array($expected, $yaml);
  218
+
  219
+        $yaml = <<<'EOF'
  220
+foo: |+
  221
+    one
  222
+    two
176 223
 
177 224
 bar: |+
178 225
     one
179 226
     two
180 227
 
  228
+
181 229
 EOF;
182 230
         $expected = array(
183 231
             'foo' => "one\ntwo\n\n",
184 232
             'bar' => "one\ntwo\n\n",
185 233
         );
186  
-        $tests['Literal block chomping keep with trailing newline'] = array($expected, $yaml);
  234
+        $tests['Literal block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
187 235
 
188 236
         $yaml = <<<'EOF'
189 237
 foo: |+
@@ -195,7 +243,7 @@ public function getBlockChompingTests()
195 243
 EOF;
196 244
         $expected = array(
197 245
             'foo' => "one\ntwo\n",
198  
-            'bar' => "one\ntwo\n",
  246
+            'bar' => "one\ntwo",
199 247
         );
200 248
         $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml);
201 249
 
@@ -203,17 +251,33 @@ public function getBlockChompingTests()
203 251
 foo: >-
204 252
     one
205 253
     two
  254
+bar: >-
  255
+    one
  256
+    two
  257
+
  258
+EOF;
  259
+        $expected = array(
  260
+            'foo' => "one two",
  261
+            'bar' => "one two",
  262
+        );
  263
+        $tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml);
  264
+
  265
+        $yaml = <<<'EOF'
  266
+foo: >-
  267
+    one
  268
+    two
206 269
 
207 270
 bar: >-
208 271
     one
209 272
     two
210 273
 
  274
+
211 275
 EOF;
212 276
         $expected = array(
213 277
             'foo' => "one two",
214 278
             'bar' => "one two",
215 279
         );
216  
-        $tests['Folded block chomping strip with trailing newline'] = array($expected, $yaml);
  280
+        $tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
217 281
 
218 282
         $yaml = <<<'EOF'
219 283
 foo: >-
@@ -233,7 +297,6 @@ public function getBlockChompingTests()
233 297
 foo: >
234 298
     one
235 299
     two
236  
-
237 300
 bar: >
238 301
     one
239 302
     two
@@ -243,37 +306,70 @@ public function getBlockChompingTests()
243 306
             'foo' => "one two\n",
244 307
             'bar' => "one two\n",
245 308
         );
246  
-        $tests['Folded block chomping clip with trailing newline'] = array($expected, $yaml);
  309
+        $tests['Folded block chomping clip with single trailing newline'] = array($expected, $yaml);
247 310
 
248 311
         $yaml = <<<'EOF'
249 312
 foo: >
250 313
     one
251 314
     two
  315
+
252 316
 bar: >
253 317
     one
254 318
     two
  319
+
  320
+
255 321
 EOF;
256 322
         $expected = array(
257 323
             'foo' => "one two\n",
258 324
             'bar' => "one two\n",
259 325
         );
  326
+        $tests['Folded block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
  327
+
  328
+        $yaml = <<<'EOF'
  329
+foo: >
  330
+    one
  331
+    two
  332
+bar: >
  333
+    one
  334
+    two
  335
+EOF;
  336
+        $expected = array(
  337
+            'foo' => "one two\n",
  338
+            'bar' => "one two",
  339
+        );
260 340
         $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
261 341
 
262 342
         $yaml = <<<'EOF'
263 343
 foo: >+
264 344
     one
265 345
     two
  346
+bar: >+
  347
+    one
  348
+    two
  349
+
  350
+EOF;
  351
+        $expected = array(
  352
+            'foo' => "one two\n",
  353
+            'bar' => "one two\n",
  354
+        );
  355
+        $tests['Folded block chomping keep with single trailing newline'] = array($expected, $yaml);
  356
+
  357
+        $yaml = <<<'EOF'
  358
+foo: >+
  359
+    one
  360
+    two
266 361
 
267 362
 bar: >+
268 363
     one
269 364
     two
270 365
 
  366
+
271 367
 EOF;
272 368
         $expected = array(
273 369
             'foo' => "one two\n\n",
274 370
             'bar' => "one two\n\n",
275 371
         );
276  
-        $tests['Folded block chomping keep with trailing newline'] = array($expected, $yaml);
  372
+        $tests['Folded block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
277 373
 
278 374
         $yaml = <<<'EOF'
279 375
 foo: >+
@@ -285,7 +381,7 @@ public function getBlockChompingTests()
285 381
 EOF;
286 382
         $expected = array(
287 383
             'foo' => "one two\n",
288  
-            'bar' => "one two\n",
  384
+            'bar' => "one two",
289 385
         );
290 386
         $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
291 387
 

0 notes on commit 77ec799

Please sign in to comment.
Something went wrong with that request. Please try again.