Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.1' into 2.2

* 2.1:
  #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

Conflicts:
	.travis.yml
	src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
	src/Symfony/Component/Routing/RouteCollection.php
  • Loading branch information...
commit 03fc97d11a2800e7da75edd5d13edf188fdbc564 2 parents e24ce2f + 8ae7d98
@fabpot fabpot authored
Showing with 270 additions and 100 deletions.
  1. +1 −0  .travis.yml
  2. +1 −1  src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
  3. +7 −2 src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
  4. +1 −0  src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php
  5. +1 −0  src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
  6. +1 −0  src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml
  7. +1 −0  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml
  8. +1 −0  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml
  9. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
  10. +5 −1 src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php
  11. +24 −1 src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
  12. +13 −9 src/Symfony/Component/HttpFoundation/Request.php
  13. +10 −6 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
  14. +6 −1 src/Symfony/Component/Process/Process.php
  15. +41 −44 src/Symfony/Component/Yaml/Parser.php
  16. +49 −23 src/Symfony/Component/Yaml/Tests/DumperTest.php
  17. +106 −10 src/Symfony/Component/Yaml/Tests/ParserTest.php
View
1  .travis.yml
@@ -12,6 +12,7 @@ matrix:
before_script:
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
+ - echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
- php src/Symfony/Component/Locale/Resources/data/build-data.php
- export USE_INTL_ICU_DATA_VERSION=1
View
2  src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -260,7 +260,7 @@ private function prepareParameters($parameters, $escape = true)
foreach ($parameters as $key => $value) {
if (is_array($value)) {
$value = $this->prepareParameters($value, $escape);
- } elseif ($value instanceof Reference) {
+ } elseif ($value instanceof Reference || is_string($value) && 0 === strpos($value, '@')) {
$value = '@'.$value;
}
View
9 src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -290,7 +290,10 @@ private function resolveServices($value)
if (is_array($value)) {
$value = array_map(array($this, 'resolveServices'), $value);
} elseif (is_string($value) && 0 === strpos($value, '@')) {
- if (0 === strpos($value, '@?')) {
+ if (0 === strpos($value, '@@')) {
+ $value = substr($value, 1);
+ $invalidBehavior = null;
+ } elseif (0 === strpos($value, '@?')) {
$value = substr($value, 2);
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} else {
@@ -305,7 +308,9 @@ private function resolveServices($value)
$strict = true;
}
- $value = new Reference($value, $invalidBehavior, $strict);
+ if (null !== $invalidBehavior) {
+ $value = new Reference($value, $invalidBehavior, $strict);
+ }
}
return $value;
View
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php
@@ -7,6 +7,7 @@
'FOO' => '%baz%',
'baz' => 'bar',
'bar' => 'foo is %%foo bar',
+ 'escape' => '@escapeme',
'values' => array(true, false, null, 0, 1000.3, 'true', 'false', 'null'),
)));
View
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php
@@ -37,6 +37,7 @@ protected function getDefaultParameters()
'foo' => '%baz%',
'baz' => 'bar',
'bar' => 'foo is %%foo bar',
+ 'escape' => '@escapeme',
'values' => array(
0 => true,
1 => false,
View
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml
@@ -7,6 +7,7 @@
<parameter key="foo">%baz%</parameter>
<parameter key="baz">bar</parameter>
<parameter key="bar">foo is %%foo bar</parameter>
+ <parameter key="escape">@escapeme</parameter>
<parameter key="values" type="collection">
<parameter>true</parameter>
<parameter>false</parameter>
View
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml
@@ -6,6 +6,7 @@ parameters:
- 0
- 1000.3
bar: foo
+ escape: @@escapeme
foo_bar: @foo_bar
MixedCase:
MixedCaseKey: value
View
1  src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml
@@ -2,5 +2,6 @@ parameters:
foo: '%baz%'
baz: bar
bar: 'foo is %%foo bar'
+ escape: '@@escapeme'
values: [true, false, null, 0, 1000.3, 'true', 'false', 'null']
View
4 src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -84,7 +84,7 @@ public function testLoadParameters()
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services2.yml');
- $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');
+ $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');
}
public function testLoadImports()
@@ -99,7 +99,7 @@ public function testLoadImports()
$loader->load('services4.yml');
$actual = $container->getParameterBag()->all();
- $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);
+ $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);
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
// Bad import throws no exception due to ignore_errors value.
View
6 src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php
@@ -65,7 +65,11 @@ public function isCsrfTokenValid($intention, $token)
*/
protected function getSessionId()
{
- if (!session_id()) {
+ if (version_compare(PHP_VERSION, '5.4', '>=')) {
+ if (PHP_SESSION_NONE === session_status()) {
+ session_start();
+ }
+ } elseif (!session_id()) {
session_start();
}
View
25 src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
@@ -22,7 +22,8 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass()
{
- @session_start();
+ ini_set('session.save_handler', 'files');
+ ini_set('session.save_path', sys_get_temp_dir());
}
protected function setUp()
@@ -37,13 +38,33 @@ protected function tearDown()
public function testGenerateCsrfToken()
{
+ session_start();
+
+ $token = $this->provider->generateCsrfToken('foo');
+
+ $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
+ }
+
+ public function testGenerateCsrfTokenOnUnstartedSession()
+ {
+ session_id('touti');
+
+ if (!version_compare(PHP_VERSION, '5.4', '>=')) {
+ $this->markTestSkipped('This test requires PHP >= 5.4');
+ }
+
+ $this->assertSame(PHP_SESSION_NONE, session_status());
+
$token = $this->provider->generateCsrfToken('foo');
$this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
+ $this->assertSame(PHP_SESSION_ACTIVE, session_status());
}
public function testIsCsrfTokenValidSucceeds()
{
+ session_start();
+
$token = sha1('SECRET'.'foo'.session_id());
$this->assertTrue($this->provider->isCsrfTokenValid('foo', $token));
@@ -51,6 +72,8 @@ public function testIsCsrfTokenValidSucceeds()
public function testIsCsrfTokenValidFails()
{
+ session_start();
+
$token = sha1('SECRET'.'bar'.session_id());
$this->assertFalse($this->provider->isCsrfTokenValid('foo', $token));
View
22 src/Symfony/Component/HttpFoundation/Request.php
@@ -1345,7 +1345,18 @@ public function getPreferredLanguage(array $locales = null)
return $locales[0];
}
- $preferredLanguages = array_values(array_intersect($preferredLanguages, $locales));
+ $extendedPreferredLanguages = array();
+ foreach ($preferredLanguages as $language) {
+ $extendedPreferredLanguages[] = $language;
+ if (false !== $position = strpos($language, '_')) {
+ $superLanguage = substr($language, 0, $position);
+ if (!in_array($superLanguage, $preferredLanguages)) {
+ $extendedPreferredLanguages[] = $superLanguage;
+ }
+ }
+ }
+
+ $preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
}
@@ -1379,11 +1390,6 @@ public function getLanguages()
for ($i = 0, $max = count($codes); $i < $max; $i++) {
if ($i == 0) {
$lang = strtolower($codes[0]);
- // First segment of compound language codes
- // is added to supported languages list
- if (!in_array($lang, $this->languages)) {
- $this->languages[] = $lang;
- }
} else {
$lang .= '_'.strtoupper($codes[$i]);
}
@@ -1391,9 +1397,7 @@ public function getLanguages()
}
}
- if (!in_array($lang, $this->languages)) {
- $this->languages[] = $lang;
- }
+ $this->languages[] = $lang;
}
return $this->languages;
View
16 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
@@ -1013,6 +1013,14 @@ public function testGetPreferredLanguage()
$request = new Request();
$request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
$this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
+
+ $request = new Request();
+ $request->headers->set('Accept-language', 'zh, en-us; q=0.8');
+ $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
+
+ $request = new Request();
+ $request->headers->set('Accept-language', 'zh, en-us; q=0.8, fr-fr; q=0.6, fr; q=0.5');
+ $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en')));
}
public function testIsXmlHttpRequest()
@@ -1083,8 +1091,8 @@ public function testGetLanguages()
$request = new Request();
$request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
- $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages());
- $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages());
+ $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages());
+ $this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages());
$request = new Request();
$request->headers->set('Accept-language', 'zh, en-us; q=0.6, en; q=0.8');
@@ -1101,10 +1109,6 @@ public function testGetLanguages()
$request = new Request();
$request->headers->set('Accept-language', 'zh, i-cherokee; q=0.6');
$this->assertEquals(array('zh', 'cherokee'), $request->getLanguages());
-
- $request = new Request();
- $request->headers->set('Accept-language', 'en-us');
- $this->assertEquals(array('en', 'en_US'), $request->getLanguages());
}
public function testGetRequestFormat()
View
7 src/Symfony/Component/Process/Process.php
@@ -131,8 +131,13 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
$this->commandline = $commandline;
$this->cwd = $cwd;
+
// on windows, if the cwd changed via chdir(), proc_open defaults to the dir where php was started
- if (null === $this->cwd && defined('PHP_WINDOWS_VERSION_BUILD')) {
+ // on gnu/linux, PHP builds with --enable-maintainer-zts are also affected
+ // @see : https://bugs.php.net/bug.php?id=51800
+ // @see : https://bugs.php.net/bug.php?id=50524
+
+ if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
$this->cwd = getcwd();
}
if (null !== $env) {
View
85 src/Symfony/Component/Yaml/Parser.php
@@ -414,64 +414,61 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
*/
private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
{
- $separator = '|' == $separator ? "\n" : ' ';
- $text = '';
-
$notEOF = $this->moveToNextLine();
-
- while ($notEOF && $this->isCurrentLineBlank()) {
- $text .= "\n";
-
- $notEOF = $this->moveToNextLine();
- }
-
if (!$notEOF) {
return '';
}
- if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#u', $this->currentLine, $matches)) {
- $this->moveToPreviousLine();
-
- return '';
+ // determine indentation if not specified
+ if (0 === $indentation) {
+ if (preg_match('/^ +/', $this->currentLine, $matches)) {
+ $indentation = strlen($matches[0]);
+ }
}
- $textIndent = $matches['indent'];
- $previousIndent = 0;
-
- $text .= $matches['text'].$separator;
- while ($this->currentLineNb + 1 < count($this->lines)) {
- $this->moveToNextLine();
-
- if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#u', $this->currentLine, $matches)) {
- if (' ' == $separator && $previousIndent != $matches['indent']) {
- $text = substr($text, 0, -1)."\n";
+ $text = '';
+ if ($indentation > 0) {
+ $pattern = sprintf('/^ {%d}(.*)$/', $indentation);
+
+ $isCurrentLineBlank = $this->isCurrentLineBlank();
+ while (
+ $notEOF && (
+ $isCurrentLineBlank ||
+ preg_match($pattern, $this->currentLine, $matches)
+ )
+ ) {
+ if ($isCurrentLineBlank) {
+ $text .= substr($this->currentLine, $indentation);
+ } else {
+ $text .= $matches[1];
}
- $previousIndent = $matches['indent'];
- $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator);
- } elseif (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches)) {
- $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n";
- } else {
- $this->moveToPreviousLine();
-
- break;
+ // newline only if not EOF
+ if ($notEOF = $this->moveToNextLine()) {
+ $text .= "\n";
+ $isCurrentLineBlank = $this->isCurrentLineBlank();
+ }
}
+ } elseif ($notEOF) {
+ $text .= "\n";
}
- if (' ' == $separator) {
- // replace last separator by a newline
- $text = preg_replace('/ (\n*)$/', "\n$1", $text);
+ if ($notEOF) {
+ $this->moveToPreviousLine();
}
- switch ($indicator) {
- case '':
- $text = preg_replace('#\n+$#s', "\n", $text);
- break;
- case '+':
- break;
- case '-':
- $text = preg_replace('#\n+$#s', '', $text);
- break;
+ // replace all non-trailing single newlines with spaces in folded blocks
+ if ('>' === $separator) {
+ preg_match('/(\n*)$/', $text, $matches);
+ $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
+ $text .= $matches[1];
+ }
+
+ // deal with trailing newlines as indicated
+ if ('' === $indicator) {
+ $text = preg_replace('/\n+$/s', "\n", $text);
+ } elseif ('-' === $indicator) {
+ $text = preg_replace('/\n+$/s', '', $text);
}
return $text;
View
72 src/Symfony/Component/Yaml/Tests/DumperTest.php
@@ -21,6 +21,21 @@ class DumperTest extends \PHPUnit_Framework_TestCase
protected $dumper;
protected $path;
+ protected $array = array(
+ '' => 'bar',
+ 'foo' => '#bar',
+ 'foo\'bar' => array(),
+ 'bar' => array(1, 'foo'),
+ 'foobar' => array(
+ 'foo' => 'bar',
+ 'bar' => array(1, 'foo'),
+ 'foobar' => array(
+ 'foo' => 'bar',
+ 'bar' => array(1, 'foo'),
+ ),
+ ),
+ );
+
protected function setUp()
{
$this->parser = new Parser();
@@ -33,6 +48,33 @@ protected function tearDown()
$this->parser = null;
$this->dumper = null;
$this->path = null;
+ $this->array = null;
+ }
+
+ public function testSetIndentation()
+ {
+ $this->dumper->setIndentation(7);
+
+$expected = <<<EOF
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+ foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0));
}
public function testSpecifications()
@@ -63,27 +105,11 @@ public function testSpecifications()
public function testInlineLevel()
{
- // inline level
- $array = array(
- '' => 'bar',
- 'foo' => '#bar',
- 'foo\'bar' => array(),
- 'bar' => array(1, 'foo'),
- 'foobar' => array(
- 'foo' => 'bar',
- 'bar' => array(1, 'foo'),
- 'foobar' => array(
- 'foo' => 'bar',
- 'bar' => array(1, 'foo'),
- ),
- ),
- );
-
$expected = <<<EOF
{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
EOF;
-$this->assertEquals($expected, $this->dumper->dump($array, -10), '->dump() takes an inline level argument');
-$this->assertEquals($expected, $this->dumper->dump($array, 0), '->dump() takes an inline level argument');
+$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
+$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
$expected = <<<EOF
'': bar
@@ -93,7 +119,7 @@ public function testInlineLevel()
foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
EOF;
- $this->assertEquals($expected, $this->dumper->dump($array, 1), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
$expected = <<<EOF
'': bar
@@ -108,7 +134,7 @@ public function testInlineLevel()
foobar: { foo: bar, bar: [1, foo] }
EOF;
- $this->assertEquals($expected, $this->dumper->dump($array, 2), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
$expected = <<<EOF
'': bar
@@ -127,7 +153,7 @@ public function testInlineLevel()
bar: [1, foo]
EOF;
- $this->assertEquals($expected, $this->dumper->dump($array, 3), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
$expected = <<<EOF
'': bar
@@ -148,8 +174,8 @@ public function testInlineLevel()
- foo
EOF;
- $this->assertEquals($expected, $this->dumper->dump($array, 4), '->dump() takes an inline level argument');
- $this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
}
public function testObjectSupportEnabled()
View
116 src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -113,17 +113,33 @@ public function getBlockChompingTests()
foo: |-
one
two
+bar: |-
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping strip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |-
+ one
+ two
bar: |-
one
two
+
EOF;
$expected = array(
'foo' => "one\ntwo",
'bar' => "one\ntwo",
);
- $tests['Literal block chomping strip with trailing newline'] = array($expected, $yaml);
+ $tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |-
@@ -143,7 +159,6 @@ public function getBlockChompingTests()
foo: |
one
two
-
bar: |
one
two
@@ -153,37 +168,70 @@ public function getBlockChompingTests()
'foo' => "one\ntwo\n",
'bar' => "one\ntwo\n",
);
- $tests['Literal block chomping clip with trailing newline'] = array($expected, $yaml);
+ $tests['Literal block chomping clip with single trailing newline'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |
one
two
+
bar: |
one
two
+
+
EOF;
$expected = array(
'foo' => "one\ntwo\n",
'bar' => "one\ntwo\n",
);
+ $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |
+ one
+ two
+bar: |
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo",
+ );
$tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |+
one
two
+bar: |+
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo\n",
+ );
+ $tests['Literal block chomping keep with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |+
+ one
+ two
bar: |+
one
two
+
EOF;
$expected = array(
'foo' => "one\ntwo\n\n",
'bar' => "one\ntwo\n\n",
);
- $tests['Literal block chomping keep with trailing newline'] = array($expected, $yaml);
+ $tests['Literal block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: |+
@@ -195,7 +243,7 @@ public function getBlockChompingTests()
EOF;
$expected = array(
'foo' => "one\ntwo\n",
- 'bar' => "one\ntwo\n",
+ 'bar' => "one\ntwo",
);
$tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml);
@@ -203,17 +251,33 @@ public function getBlockChompingTests()
foo: >-
one
two
+bar: >-
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one two",
+ 'bar' => "one two",
+ );
+ $tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >-
+ one
+ two
bar: >-
one
two
+
EOF;
$expected = array(
'foo' => "one two",
'bar' => "one two",
);
- $tests['Folded block chomping strip with trailing newline'] = array($expected, $yaml);
+ $tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: >-
@@ -233,7 +297,6 @@ public function getBlockChompingTests()
foo: >
one
two
-
bar: >
one
two
@@ -243,37 +306,70 @@ public function getBlockChompingTests()
'foo' => "one two\n",
'bar' => "one two\n",
);
- $tests['Folded block chomping clip with trailing newline'] = array($expected, $yaml);
+ $tests['Folded block chomping clip with single trailing newline'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: >
one
two
+
bar: >
one
two
+
+
EOF;
$expected = array(
'foo' => "one two\n",
'bar' => "one two\n",
);
+ $tests['Folded block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >
+ one
+ two
+bar: >
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => "one two",
+ );
$tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: >+
one
two
+bar: >+
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => "one two\n",
+ );
+ $tests['Folded block chomping keep with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >+
+ one
+ two
bar: >+
one
two
+
EOF;
$expected = array(
'foo' => "one two\n\n",
'bar' => "one two\n\n",
);
- $tests['Folded block chomping keep with trailing newline'] = array($expected, $yaml);
+ $tests['Folded block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
$yaml = <<<'EOF'
foo: >+
@@ -285,7 +381,7 @@ public function getBlockChompingTests()
EOF;
$expected = array(
'foo' => "one two\n",
- 'bar' => "one two\n",
+ 'bar' => "one two",
);
$tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
Please sign in to comment.
Something went wrong with that request. Please try again.