[Yaml] fix multiline block handling

This commit is contained in:
Christian Flothmann 2017-05-22 11:14:20 +02:00
parent 005b4b74d5
commit a2079d6e2e
2 changed files with 53 additions and 3 deletions

View File

@ -368,7 +368,11 @@ class Parser
foreach ($this->lines as $line) {
try {
$parsedLine = Inline::parse($line, $flags, $this->refs);
if (isset($line[0]) && ('"' === $line[0] || "'" === $line[0])) {
$parsedLine = $line;
} else {
$parsedLine = Inline::parse($line, $flags, $this->refs);
}
if (!is_string($parsedLine)) {
$parseError = true;

View File

@ -1561,8 +1561,18 @@ EOT;
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
}
public function testParseMultiLineMappingValue()
/**
* @dataProvider multiLineDataProvider
*/
public function testParseMultiLineMappingValue($yaml, $expected, $parseError)
{
$this->assertEquals($expected, $this->parser->parse($yaml));
}
public function multiLineDataProvider()
{
$tests = array();
$yaml = <<<'EOF'
foo:
- bar:
@ -1579,7 +1589,43 @@ EOF;
),
);
$this->assertEquals($expected, $this->parser->parse($yaml));
$tests[] = array($yaml, $expected, false);
$yaml = <<<'EOF'
bar
"foo"
EOF;
$expected = 'bar "foo"';
$tests[] = array($yaml, $expected, false);
$yaml = <<<'EOF'
bar
"foo
EOF;
$expected = 'bar "foo';
$tests[] = array($yaml, $expected, false);
$yaml = <<<'EOF'
bar
'foo'
EOF;
$expected = "bar\n'foo'";
$tests[] = array($yaml, $expected, false);
$yaml = <<<'EOF'
bar
foo'
EOF;
$expected = "bar\nfoo'";
$tests[] = array($yaml, $expected, false);
return $tests;
}
public function testTaggedInlineMapping()