update v1.0.6

This commit is contained in:
sujitprasad
2016-02-16 22:42:08 +05:30
parent e6b579d67b
commit 073a49a8af
587 changed files with 21487 additions and 22766 deletions

View File

@@ -90,7 +90,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
public function testEndOfTheDocumentMarker()
{
$yaml = <<<EOF
$yaml = <<<'EOF'
--- %YAML:1.0
foo
...
@@ -426,15 +426,19 @@ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
bar: 1
EOF;
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
}
public function testObjectSupportDisabledButNoExceptions()
{
$input = <<<EOF
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
bar: 1
EOF;
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
}
/**
* @dataProvider invalidDumpedObjectProvider
*/
public function testObjectSupportDisabledButNoExceptions($input)
{
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
}
@@ -460,12 +464,39 @@ EOF;
$this->assertEquals('cat', $result->fiz);
}
public function testObjectForMapIsAppliedAfterParsing()
{
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->baz = 'foobar';
$this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true));
}
/**
* @dataProvider invalidDumpedObjectProvider
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testObjectsSupportDisabledWithExceptions()
public function testObjectsSupportDisabledWithExceptions($yaml)
{
$this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false);
$this->parser->parse($yaml, true, false);
}
public function invalidDumpedObjectProvider()
{
$yamlTag = <<<EOF
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
bar: 1
EOF;
$localTag = <<<EOF
foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
bar: 1
EOF;
return array(
'yaml-tag' => array($yamlTag),
'local-tag' => array($localTag),
);
}
/**
@@ -495,7 +526,7 @@ EOF;
*/
public function testUnindentedCollectionException()
{
$yaml = <<<EOF
$yaml = <<<'EOF'
collection:
-item1
@@ -512,7 +543,7 @@ EOF;
*/
public function testShortcutKeyUnindentedCollectionException()
{
$yaml = <<<EOF
$yaml = <<<'EOF'
collection:
- key: foo
@@ -529,7 +560,7 @@ EOF;
*/
public function testMultipleDocumentsNotSupportedException()
{
Yaml::parse(<<<EOL
Yaml::parse(<<<'EOL'
# Ranking of 1998 home runs
---
- Mark McGwire
@@ -549,7 +580,7 @@ EOL
*/
public function testSequenceInAMapping()
{
Yaml::parse(<<<EOF
Yaml::parse(<<<'EOF'
yaml:
hash: me
- array stuff
@@ -562,7 +593,7 @@ EOF
*/
public function testMappingInASequence()
{
Yaml::parse(<<<EOF
Yaml::parse(<<<'EOF'
yaml:
- array stuff
hash: me
@@ -629,7 +660,7 @@ EOD;
public function testEmptyValue()
{
$input = <<<EOF
$input = <<<'EOF'
hash:
EOF;
@@ -647,7 +678,7 @@ EOF;
'class' => 'Bar',
),
),
), Yaml::parse(<<<EOF
), Yaml::parse(<<<'EOF'
# comment 1
services:
# comment 2
@@ -664,7 +695,7 @@ EOF
public function testStringBlockWithComments()
{
$this->assertEquals(array('content' => <<<EOT
$this->assertEquals(array('content' => <<<'EOT'
# comment 1
header
@@ -675,7 +706,7 @@ header
footer # comment3
EOT
), Yaml::parse(<<<EOF
), Yaml::parse(<<<'EOF'
content: |
# comment 1
header
@@ -692,7 +723,7 @@ EOF
public function testFoldedStringBlockWithComments()
{
$this->assertEquals(array(array('content' => <<<EOT
$this->assertEquals(array(array('content' => <<<'EOT'
# comment 1
header
@@ -703,7 +734,7 @@ header
footer # comment3
EOT
)), Yaml::parse(<<<EOF
)), Yaml::parse(<<<'EOF'
-
content: |
# comment 1
@@ -723,7 +754,7 @@ EOF
{
$this->assertEquals(array(array(
'title' => 'some title',
'content' => <<<EOT
'content' => <<<'EOT'
# comment 1
header
@@ -734,7 +765,7 @@ header
footer # comment3
EOT
)), Yaml::parse(<<<EOF
)), Yaml::parse(<<<'EOF'
-
title: some title
content: |
@@ -763,7 +794,7 @@ EOF
'map' => array('key' => 'var-value'),
'list_in_map' => array('key' => array('var-value')),
'map_in_map' => array('foo' => array('bar' => 'var-value')),
), Yaml::parse(<<<EOF
), Yaml::parse(<<<'EOF'
var: &var var-value
scalar: *var
list: [ *var ]
@@ -779,7 +810,7 @@ EOF
public function testYamlDirective()
{
$yaml = <<<EOF
$yaml = <<<'EOF'
%YAML 1.2
---
foo: 1
@@ -790,7 +821,7 @@ EOF;
public function testFloatKeys()
{
$yaml = <<<EOF
$yaml = <<<'EOF'
foo:
1.2: "bar"
1.3: "baz"
@@ -839,7 +870,9 @@ EOT;
public function getCommentLikeStringInScalarBlockData()
{
$yaml1 = <<<EOT
$tests = array();
$yaml = <<<'EOT'
pages:
-
title: some title
@@ -854,11 +887,11 @@ pages:
footer # comment3
EOT;
$expected1 = array(
$expected = array(
'pages' => array(
array(
'title' => 'some title',
'content' => <<<EOT
'content' => <<<'EOT'
# comment 1
header
@@ -873,8 +906,9 @@ EOT
),
),
);
$tests[] = array($yaml, $expected);
$yaml2 = <<<EOT
$yaml = <<<'EOT'
test: |
foo
# bar
@@ -889,8 +923,8 @@ collection:
# bar
baz
EOT;
$expected2 = array(
'test' => <<<EOT
$expected = array(
'test' => <<<'EOT'
foo
# bar
baz
@@ -899,7 +933,7 @@ EOT
,
'collection' => array(
array(
'one' => <<<EOT
'one' => <<<'EOT'
foo
# bar
baz
@@ -907,7 +941,7 @@ EOT
,
),
array(
'two' => <<<EOT
'two' => <<<'EOT'
foo
# bar
baz
@@ -916,11 +950,47 @@ EOT
),
),
);
$tests[] = array($yaml, $expected);
return array(
array($yaml1, $expected1),
array($yaml2, $expected2),
$yaml = <<<EOT
foo:
bar:
scalar-block: >
line1
line2>
baz:
# comment
foobar: ~
EOT;
$expected = array(
'foo' => array(
'bar' => array(
'scalar-block' => 'line1 line2>',
),
'baz' => array(
'foobar' => null,
),
),
);
$tests[] = array($yaml, $expected);
$yaml = <<<'EOT'
a:
b: hello
# c: |
# first row
# second row
d: hello
EOT;
$expected = array(
'a' => array(
'b' => 'hello',
'd' => 'hello',
),
);
$tests[] = array($yaml, $expected);
return $tests;
}
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()