You are here

public function ParserTest::getCommentLikeStringInScalarBlockData in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/symfony/yaml/Tests/ParserTest.php \Symfony\Component\Yaml\Tests\ParserTest::getCommentLikeStringInScalarBlockData()

File

vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php, line 788

Class

ParserTest

Namespace

Symfony\Component\Yaml\Tests

Code

public function getCommentLikeStringInScalarBlockData() {
  $tests = array();
  $yaml = <<<'EOT'
pages:
    -
        title: some title
        content: |
            # comment 1
            header

                # comment 2
                <body>
                    <h1>title</h1>
                </body>

            footer # comment3
EOT;
  $expected = array(
    'pages' => array(
      array(
        'title' => 'some title',
        'content' => <<<'EOT'
# comment 1
header

    # comment 2
    <body>
        <h1>title</h1>
    </body>

footer # comment3
EOT
,
      ),
    ),
  );
  $tests[] = array(
    $yaml,
    $expected,
  );
  $yaml = <<<'EOT'
test: |
    foo
    # bar
    baz
collection:
    - one: |
        foo
        # bar
        baz
    - two: |
        foo
        # bar
        baz
EOT;
  $expected = array(
    'test' => <<<'EOT'
foo
# bar
baz

EOT
,
    'collection' => array(
      array(
        'one' => <<<'EOT'
foo
# bar
baz

EOT
,
      ),
      array(
        'two' => <<<'EOT'
foo
# bar
baz
EOT
,
      ),
    ),
  );
  $tests[] = array(
    $yaml,
    $expected,
  );
  $yaml = <<<EOT
foo:
  bar:
    scalar-block: >
      line1
      line2>
  baz:
# comment
    foobar: ~
EOT;
  $expected = array(
    'foo' => array(
      'bar' => array(
        'scalar-block' => "line1 line2>\n",
      ),
      '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;
}