public function DumperTest::testInlineLevel

File

drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php, line 64

Class

DumperTest

Namespace

Symfony\Component\Yaml\Tests

Code

public function testInlineLevel() {

  // inline level
  $array = array(
    '' => 'bar',
    'foo' => '#bar',
    'foo\'bar' => array(),
    'bar' => array(
      1,
      'foo',
    ),
    'foobar' => array(
      'foo' => 'bar',
      'bar' => array(
        1,
        'foo',
      ),
      'foobar' => array(
        'foo' => 'bar',
        'bar' => array(
          1,
          'foo',
        ),
      ),
    ),
  );
  $expected = <<<EOF
{ '': bar, foo: '#bar', 'foo''bar': {  }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
EOF;
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, -10), '->dump() takes an inline level argument');
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 0), '->dump() takes an inline level argument');
  $expected = <<<EOF
'': bar
foo: '#bar'
'foo''bar': {  }
bar: [1, foo]
foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }

EOF;
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 1), '->dump() takes an inline level argument');
  $expected = <<<EOF
'': bar
foo: '#bar'
'foo''bar': {  }
bar:
    - 1
    - foo
foobar:
    foo: bar
    bar: [1, foo]
    foobar: { foo: bar, bar: [1, foo] }

EOF;
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 2), '->dump() takes an inline level argument');
  $expected = <<<EOF
'': bar
foo: '#bar'
'foo''bar': {  }
bar:
    - 1
    - foo
foobar:
    foo: bar
    bar:
        - 1
        - foo
    foobar:
        foo: bar
        bar: [1, foo]

EOF;
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 3), '->dump() takes an inline level argument');
  $expected = <<<EOF
'': bar
foo: '#bar'
'foo''bar': {  }
bar:
    - 1
    - foo
foobar:
    foo: bar
    bar:
        - 1
        - foo
    foobar:
        foo: bar
        bar:
            - 1
            - foo

EOF;
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 4), '->dump() takes an inline level argument');
  $this
    ->assertEquals($expected, $this->dumper
    ->dump($array, 10), '->dump() takes an inline level argument');
}