8000 Test for Issue #26065: leading spaces in YAML multi-line string literals · eyfs/symfony@752f8d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 752f8d2

Browse files
committed
Test for Issue symfony#26065: leading spaces in YAML multi-line string literals
When dumping an object to YAML. If the first line of a mult-line string literal starts with spaces then the YAML spec says you need to use a [block indentation indicator][1]. [1]: http://www.yaml.org/spec/1.2/spec.html#id2793979
1 parent 717e1c3 commit 752f8d2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/Yaml/Tests/DumperTest.php

Lines changed: 11 additions & 0 deletions
@@ -454,6 +454,17 @@ public function testDumpMultiLineStringAsScalarBlock()
Original file line numberDiff line numberDiff line change
454454
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
455455
}
456456

457+
public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace()
458+
{
459+
$data = array(
460+
'data' => array(
461+
'multi_line' => " the first line has leading spaces\nThe second line does not.",
462+
),
463+
);
464+
465+
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
466+
}
467+
457468
public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
458469
{
459470
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data:
2+
multi_line: |4
3+
the first line has leading spaces
4+
The second line does not.

0 commit comments

Comments
 (0)
0