public function ParserTest::getObjectForMapTests in Lockr 7.3
File
- vendor/
symfony/ yaml/ Tests/ ParserTest.php, line 548
Class
Namespace
Symfony\Component\Yaml\TestsCode
public function getObjectForMapTests() {
$tests = [];
$yaml = <<<'EOF'
foo:
fiz: [cat]
EOF;
$expected = new \stdClass();
$expected->foo = new \stdClass();
$expected->foo->fiz = [
'cat',
];
$tests['mapping'] = [
$yaml,
$expected,
];
$yaml = '{ "foo": "bar", "fiz": "cat" }';
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->fiz = 'cat';
$tests['inline-mapping'] = [
$yaml,
$expected,
];
$yaml = "foo: bar\nbaz: foobar";
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->baz = 'foobar';
$tests['object-for-map-is-applied-after-parsing'] = [
$yaml,
$expected,
];
$yaml = <<<'EOT'
array:
- key: one
- key: two
EOT;
$expected = new \stdClass();
$expected->array = [];
$expected->array[0] = new \stdClass();
$expected->array[0]->key = 'one';
$expected->array[1] = new \stdClass();
$expected->array[1]->key = 'two';
$tests['nest-map-and-sequence'] = [
$yaml,
$expected,
];
$yaml = <<<'YAML'
map:
1: one
2: two
YAML;
$expected = new \stdClass();
$expected->map = new \stdClass();
$expected->map->{1} = 'one';
$expected->map->{2} = 'two';
$tests['numeric-keys'] = [
$yaml,
$expected,
];
$yaml = <<<'YAML'
map:
'0': one
'1': two
YAML;
$expected = new \stdClass();
$expected->map = new \stdClass();
$expected->map->{0} = 'one';
$expected->map->{1} = 'two';
$tests['zero-indexed-numeric-keys'] = [
$yaml,
$expected,
];
return $tests;
}