update v1.0.4
This commit is contained in:
@@ -145,3 +145,11 @@ php: |
|
||||
array(
|
||||
'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
|
||||
)
|
||||
---
|
||||
test: Backslashes
|
||||
yaml: |
|
||||
{ single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" }
|
||||
php: |
|
||||
array(
|
||||
'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var'
|
||||
)
|
||||
|
@@ -3,7 +3,7 @@ test: Some characters at the beginning of a string must be escaped
|
||||
brief: >
|
||||
Some characters at the beginning of a string must be escaped
|
||||
yaml: |
|
||||
foo: | bar
|
||||
foo: '| bar'
|
||||
php: |
|
||||
array('foo' => '| bar')
|
||||
---
|
||||
|
51
vendor/symfony/yaml/Tests/InlineTest.php
vendored
51
vendor/symfony/yaml/Tests/InlineTest.php
vendored
@@ -58,10 +58,8 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('1.2', Inline::dump(1.2));
|
||||
$this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
|
||||
} finally {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
} catch (\Exception $e) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +70,23 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Found unknown escape character "\V".
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\Var"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
@@ -173,6 +188,36 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
Inline::parse('{ foo: * #foo }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReservedIndicators
|
||||
* @expectedException Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||
{
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getReservedIndicators()
|
||||
{
|
||||
return array(array('@'), array('`'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getScalarIndicators
|
||||
* @expectedException Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||
{
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getScalarIndicators()
|
||||
{
|
||||
return array(array('|'), array('>'));
|
||||
}
|
||||
|
||||
public function getTestsForParse()
|
||||
{
|
||||
return array(
|
||||
|
12
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
12
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
@@ -18,11 +18,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetMessage()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
} else {
|
||||
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
|
||||
}
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
@@ -30,11 +26,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetMessageWithUnicodeInFilename()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
} else {
|
||||
$message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
|
||||
}
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
|
195
vendor/symfony/yaml/Tests/ParserTest.php
vendored
195
vendor/symfony/yaml/Tests/ParserTest.php
vendored
@@ -438,6 +438,28 @@ EOF;
|
||||
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
|
||||
}
|
||||
|
||||
public function testObjectForMapEnabledWithMapping()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
foo:
|
||||
fiz: [cat]
|
||||
EOF;
|
||||
$result = $this->parser->parse($yaml, false, false, true);
|
||||
|
||||
$this->assertInstanceOf('stdClass', $result);
|
||||
$this->assertInstanceOf('stdClass', $result->foo);
|
||||
$this->assertEquals(array('cat'), $result->foo->fiz);
|
||||
}
|
||||
|
||||
public function testObjectForMapEnabledWithInlineMapping()
|
||||
{
|
||||
$result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', false, false, true);
|
||||
|
||||
$this->assertInstanceOf('stdClass', $result);
|
||||
$this->assertEquals('bar', $result->foo);
|
||||
$this->assertEquals('cat', $result->fiz);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
@@ -572,8 +594,6 @@ EOF
|
||||
*
|
||||
* @see http://yaml.org/spec/1.2/spec.html#id2759572
|
||||
* @see http://yaml.org/spec/1.1/#id932806
|
||||
*
|
||||
* @covers \Symfony\Component\Yaml\Parser::parse
|
||||
*/
|
||||
public function testMappingDuplicateKeyBlock()
|
||||
{
|
||||
@@ -593,9 +613,6 @@ EOD;
|
||||
$this->assertSame($expected, Yaml::parse($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Symfony\Component\Yaml\Inline::parseMapping
|
||||
*/
|
||||
public function testMappingDuplicateKeyFlow()
|
||||
{
|
||||
$input = <<<EOD
|
||||
@@ -788,6 +805,174 @@ EOF;
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A colon cannot be used in an unquoted mapping value
|
||||
*/
|
||||
public function testColonInMappingValueException()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
foo: bar: baz
|
||||
EOF;
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
||||
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
foo:
|
||||
bar: foobar # Note: a comment after a colon
|
||||
EOT;
|
||||
|
||||
$this->assertSame(array('foo' => array('bar' => 'foobar')), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCommentLikeStringInScalarBlockData
|
||||
*/
|
||||
public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expectedParserResult)
|
||||
{
|
||||
$this->assertSame($expectedParserResult, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function getCommentLikeStringInScalarBlockData()
|
||||
{
|
||||
$yaml1 = <<<EOT
|
||||
pages:
|
||||
-
|
||||
title: some title
|
||||
content: |
|
||||
# comment 1
|
||||
header
|
||||
|
||||
# comment 2
|
||||
<body>
|
||||
<h1>title</h1>
|
||||
</body>
|
||||
|
||||
footer # comment3
|
||||
EOT;
|
||||
$expected1 = array(
|
||||
'pages' => array(
|
||||
array(
|
||||
'title' => 'some title',
|
||||
'content' => <<<EOT
|
||||
# comment 1
|
||||
header
|
||||
|
||||
# comment 2
|
||||
<body>
|
||||
<h1>title</h1>
|
||||
</body>
|
||||
|
||||
footer # comment3
|
||||
EOT
|
||||
,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$yaml2 = <<<EOT
|
||||
test: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
collection:
|
||||
- one: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
- two: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT;
|
||||
$expected2 = array(
|
||||
'test' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
|
||||
EOT
|
||||
,
|
||||
'collection' => array(
|
||||
array(
|
||||
'one' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT
|
||||
,
|
||||
),
|
||||
array(
|
||||
'two' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT
|
||||
,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return array(
|
||||
array($yaml1, $expected1),
|
||||
array($yaml2, $expected2),
|
||||
);
|
||||
}
|
||||
|
||||
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
test: >
|
||||
<h2>A heading</h2>
|
||||
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT;
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'test' => <<<EOT
|
||||
<h2>A heading</h2>
|
||||
<ul> <li>a list</li> <li>may be a good example</li> </ul>
|
||||
EOT
|
||||
,
|
||||
),
|
||||
$this->parser->parse($yaml)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
test: >
|
||||
<h2>A heading</h2>
|
||||
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT;
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'test' => <<<EOT
|
||||
<h2>A heading</h2>
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT
|
||||
,
|
||||
),
|
||||
$this->parser->parse($yaml)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class B
|
||||
|
12
vendor/symfony/yaml/Tests/YamlTest.php
vendored
12
vendor/symfony/yaml/Tests/YamlTest.php
vendored
@@ -22,16 +22,4 @@ class YamlTest extends \PHPUnit_Framework_TestCase
|
||||
$parsed = Yaml::parse($yml);
|
||||
$this->assertEquals($data, $parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyParseFromFile()
|
||||
{
|
||||
$filename = __DIR__.'/Fixtures/index.yml';
|
||||
$contents = file_get_contents($filename);
|
||||
$parsedByFilename = Yaml::parse($filename);
|
||||
$parsedByContents = Yaml::parse($contents);
|
||||
$this->assertEquals($parsedByFilename, $parsedByContents);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user