First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
139
vendor/symfony/yaml/Tests/Command/LintCommandTest.php
vendored
Normal file
139
vendor/symfony/yaml/Tests/Command/LintCommandTest.php
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Command\LintCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* Tests the YamlLintCommand.
|
||||
*
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
*/
|
||||
class LintCommandTest extends TestCase
|
||||
{
|
||||
private $files;
|
||||
|
||||
public function testLintCorrectFile()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile('foo: bar');
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertRegExp('/^\/\/ OK in /', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testLintIncorrectFile()
|
||||
{
|
||||
$incorrectContent = '
|
||||
foo:
|
||||
bar';
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile($incorrectContent);
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
|
||||
|
||||
$this->assertEquals(1, $ret, 'Returns 1 in case of error');
|
||||
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testConstantAsKey()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
!php/const 'Symfony\Component\Yaml\Tests\Command\Foo::TEST': bar
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
|
||||
}
|
||||
|
||||
public function testCustomTags()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo: !my_tag {foo: bar}
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml), '--parse-tags' => true), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
|
||||
}
|
||||
|
||||
public function testCustomTagsError()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo: !my_tag {foo: bar}
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testLintFileNotReadable()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile('');
|
||||
unlink($filename);
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Path to the new file
|
||||
*/
|
||||
private function createFile($content)
|
||||
{
|
||||
$filename = tempnam(sys_get_temp_dir().'/framework-yml-lint-test', 'sf-');
|
||||
file_put_contents($filename, $content);
|
||||
|
||||
$this->files[] = $filename;
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
protected function createCommandTester()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new LintCommand());
|
||||
$command = $application->find('lint:yaml');
|
||||
|
||||
return new CommandTester($command);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->files = array();
|
||||
@mkdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
const TEST = 'foo';
|
||||
}
|
478
vendor/symfony/yaml/Tests/DumperTest.php
vendored
Normal file
478
vendor/symfony/yaml/Tests/DumperTest.php
vendored
Normal file
|
@ -0,0 +1,478 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class DumperTest extends TestCase
|
||||
{
|
||||
protected $parser;
|
||||
protected $dumper;
|
||||
protected $path;
|
||||
|
||||
protected $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'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = new Parser();
|
||||
$this->dumper = new Dumper();
|
||||
$this->path = __DIR__.'/Fixtures';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
$this->dumper = null;
|
||||
$this->path = null;
|
||||
$this->array = null;
|
||||
}
|
||||
|
||||
public function testIndentationInConstructor()
|
||||
{
|
||||
$dumper = new Dumper(7);
|
||||
$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, $dumper->dump($this->array, 4, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testSetIndentation()
|
||||
{
|
||||
$this->dumper->setIndentation(7);
|
||||
|
||||
$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($this->array, 4, 0));
|
||||
}
|
||||
|
||||
public function testSpecifications()
|
||||
{
|
||||
$files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
|
||||
foreach ($files as $file) {
|
||||
$yamls = file_get_contents($this->path.'/'.$file.'.yml');
|
||||
|
||||
// split YAMLs documents
|
||||
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
||||
if (!$yaml) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$test = $this->parser->parse($yaml);
|
||||
if (isset($test['dump_skip']) && $test['dump_skip']) {
|
||||
continue;
|
||||
} elseif (isset($test['todo']) && $test['todo']) {
|
||||
// TODO
|
||||
} else {
|
||||
eval('$expected = '.trim($test['php']).';');
|
||||
$this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testInlineLevel()
|
||||
{
|
||||
$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($this->array, -10), '->dump() takes an inline level argument');
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->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($this->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($this->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($this->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($this->array, 4), '->dump() takes an inline level argument');
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
|
||||
}
|
||||
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_OBJECT);
|
||||
|
||||
$this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testObjectSupportEnabledPassingTrue()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
|
||||
|
||||
$this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
|
||||
|
||||
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
|
||||
*/
|
||||
public function testObjectSupportDisabledWithExceptions()
|
||||
{
|
||||
$this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
|
||||
*/
|
||||
public function testObjectSupportDisabledWithExceptionsPassingTrue()
|
||||
{
|
||||
$this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true);
|
||||
}
|
||||
|
||||
public function testEmptyArray()
|
||||
{
|
||||
$dump = $this->dumper->dump(array());
|
||||
$this->assertEquals('{ }', $dump);
|
||||
|
||||
$dump = $this->dumper->dump(array(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
|
||||
$this->assertEquals('[]', $dump);
|
||||
|
||||
$dump = $this->dumper->dump(array(), 9, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
|
||||
$this->assertEquals('[]', $dump);
|
||||
|
||||
$dump = $this->dumper->dump(new \ArrayObject(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$this->assertEquals('{ }', $dump);
|
||||
|
||||
$dump = $this->dumper->dump(new \stdClass(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$this->assertEquals('{ }', $dump);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getEscapeSequences
|
||||
*/
|
||||
public function testEscapedEscapeSequencesInQuotedScalar($input, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->dumper->dump($input));
|
||||
}
|
||||
|
||||
public function getEscapeSequences()
|
||||
{
|
||||
return array(
|
||||
'empty string' => array('', "''"),
|
||||
'null' => array("\x0", '"\\0"'),
|
||||
'bell' => array("\x7", '"\\a"'),
|
||||
'backspace' => array("\x8", '"\\b"'),
|
||||
'horizontal-tab' => array("\t", '"\\t"'),
|
||||
'line-feed' => array("\n", '"\\n"'),
|
||||
'vertical-tab' => array("\v", '"\\v"'),
|
||||
'form-feed' => array("\xC", '"\\f"'),
|
||||
'carriage-return' => array("\r", '"\\r"'),
|
||||
'escape' => array("\x1B", '"\\e"'),
|
||||
'space' => array(' ', "' '"),
|
||||
'double-quote' => array('"', "'\"'"),
|
||||
'slash' => array('/', '/'),
|
||||
'backslash' => array('\\', '\\'),
|
||||
'next-line' => array("\xC2\x85", '"\\N"'),
|
||||
'non-breaking-space' => array("\xc2\xa0", '"\\_"'),
|
||||
'line-separator' => array("\xE2\x80\xA8", '"\\L"'),
|
||||
'paragraph-separator' => array("\xE2\x80\xA9", '"\\P"'),
|
||||
'colon' => array(':', "':'"),
|
||||
);
|
||||
}
|
||||
|
||||
public function testBinaryDataIsDumpedBase64Encoded()
|
||||
{
|
||||
$binaryData = file_get_contents(__DIR__.'/Fixtures/arrow.gif');
|
||||
$expected = '{ data: !!binary '.base64_encode($binaryData).' }';
|
||||
|
||||
$this->assertSame($expected, $this->dumper->dump(array('data' => $binaryData)));
|
||||
}
|
||||
|
||||
public function testNonUtf8DataIsDumpedBase64Encoded()
|
||||
{
|
||||
// "für" (ISO-8859-1 encoded)
|
||||
$this->assertSame('!!binary ZsM/cg==', $this->dumper->dump("f\xc3\x3fr"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider objectAsMapProvider
|
||||
*/
|
||||
public function testDumpObjectAsMap($object, $expected)
|
||||
{
|
||||
$yaml = $this->dumper->dump($object, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$this->assertEquals($expected, Yaml::parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
|
||||
}
|
||||
|
||||
public function objectAsMapProvider()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$bar = new \stdClass();
|
||||
$bar->class = 'classBar';
|
||||
$bar->args = array('bar');
|
||||
$zar = new \stdClass();
|
||||
$foo = new \stdClass();
|
||||
$foo->bar = $bar;
|
||||
$foo->zar = $zar;
|
||||
$object = new \stdClass();
|
||||
$object->foo = $foo;
|
||||
$tests['stdClass'] = array($object, $object);
|
||||
|
||||
$arrayObject = new \ArrayObject();
|
||||
$arrayObject['foo'] = 'bar';
|
||||
$arrayObject['baz'] = 'foobar';
|
||||
$parsedArrayObject = new \stdClass();
|
||||
$parsedArrayObject->foo = 'bar';
|
||||
$parsedArrayObject->baz = 'foobar';
|
||||
$tests['ArrayObject'] = array($arrayObject, $parsedArrayObject);
|
||||
|
||||
$a = new A();
|
||||
$tests['arbitrary-object'] = array($a, null);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \ArrayObject(array('deep1' => 'd', 'deep2' => 'e'));
|
||||
$inner = new \ArrayObject(array('inner1' => 'b', 'inner2' => 'c', 'inner3' => $deep));
|
||||
$outer = new \ArrayObject(array('outer1' => 'a', 'outer2' => $inner));
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$expected = <<<YAML
|
||||
outer1: a
|
||||
outer2:
|
||||
inner1: b
|
||||
inner2: c
|
||||
inner3: { deep1: d, deep2: e }
|
||||
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesWithNumericKeysInlined()
|
||||
{
|
||||
$deep = new \ArrayObject(array('d', 'e'));
|
||||
$inner = new \ArrayObject(array('b', 'c', $deep));
|
||||
$outer = new \ArrayObject(array('a', $inner));
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$expected = <<<YAML
|
||||
{ 0: a, 1: { 0: b, 1: c, 2: { 0: d, 1: e } } }
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesWithNumericKeysRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \ArrayObject(array('d', 'e'));
|
||||
$inner = new \ArrayObject(array('b', 'c', $deep));
|
||||
$outer = new \ArrayObject(array('a', $inner));
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$expected = <<<YAML
|
||||
0: a
|
||||
1:
|
||||
0: b
|
||||
1: c
|
||||
2: { 0: d, 1: e }
|
||||
|
||||
YAML;
|
||||
$this->assertEquals($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpEmptyArrayObjectInstanceAsMap()
|
||||
{
|
||||
$this->assertSame('{ }', $this->dumper->dump(new \ArrayObject(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
|
||||
}
|
||||
|
||||
public function testDumpEmptyStdClassInstanceAsMap()
|
||||
{
|
||||
$this->assertSame('{ }', $this->dumper->dump(new \stdClass(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
|
||||
}
|
||||
|
||||
public function testDumpingStdClassInstancesRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \stdClass();
|
||||
$deep->deep1 = 'd';
|
||||
$deep->deep2 = 'e';
|
||||
|
||||
$inner = new \stdClass();
|
||||
$inner->inner1 = 'b';
|
||||
$inner->inner2 = 'c';
|
||||
$inner->inner3 = $deep;
|
||||
|
||||
$outer = new \stdClass();
|
||||
$outer->outer1 = 'a';
|
||||
$outer->outer2 = $inner;
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$expected = <<<YAML
|
||||
outer1: a
|
||||
outer2:
|
||||
inner1: b
|
||||
inner2: c
|
||||
inner3: { deep1: d, deep2: e }
|
||||
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpMultiLineStringAsScalarBlock()
|
||||
{
|
||||
$data = array(
|
||||
'data' => array(
|
||||
'single_line' => 'foo bar baz',
|
||||
'multi_line' => "foo\nline with trailing spaces:\n \nbar\r\ninteger like line:\n123456789\nempty line:\n\nbaz",
|
||||
'nested_inlined_multi_line_string' => array(
|
||||
'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testZeroIndentationThrowsException()
|
||||
{
|
||||
new Dumper(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testNegativeIndentationThrowsException()
|
||||
{
|
||||
new Dumper(-4);
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
{
|
||||
public $a = 'foo';
|
||||
}
|
31
vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml
vendored
Normal file
31
vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
--- %YAML:1.0
|
||||
test: Simple Alias Example
|
||||
brief: >
|
||||
If you need to refer to the same item of data twice,
|
||||
you can give that item an alias. The alias is a plain
|
||||
string, starting with an ampersand. The item may then
|
||||
be referred to by the alias throughout your document
|
||||
by using an asterisk before the name of the alias.
|
||||
This is called an anchor.
|
||||
yaml: |
|
||||
- &showell Steve
|
||||
- Clark
|
||||
- Brian
|
||||
- Oren
|
||||
- *showell
|
||||
php: |
|
||||
array('Steve', 'Clark', 'Brian', 'Oren', 'Steve')
|
||||
|
||||
---
|
||||
test: Alias of a Mapping
|
||||
brief: >
|
||||
An alias can be used on any item of data, including
|
||||
sequences, mappings, and other complex data types.
|
||||
yaml: |
|
||||
- &hello
|
||||
Meat: pork
|
||||
Starch: potato
|
||||
- banana
|
||||
- *hello
|
||||
php: |
|
||||
array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato'))
|
202
vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
Normal file
202
vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
--- %YAML:1.0
|
||||
test: Simple Sequence
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
- banana
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', 'banana', 'carrot')
|
||||
---
|
||||
test: Sequence With Item Being Null In The Middle
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
-
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', null, 'carrot')
|
||||
---
|
||||
test: Sequence With Last Item Being Null
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
- banana
|
||||
-
|
||||
php: |
|
||||
array('apple', 'banana', null)
|
||||
---
|
||||
test: Nested Sequences
|
||||
brief: |
|
||||
You can include a sequence within another
|
||||
sequence by giving the sequence an empty
|
||||
dash, followed by an indented list.
|
||||
yaml: |
|
||||
-
|
||||
- foo
|
||||
- bar
|
||||
- baz
|
||||
php: |
|
||||
array(array('foo', 'bar', 'baz'))
|
||||
---
|
||||
test: Mixed Sequences
|
||||
brief: |
|
||||
Sequences can contain any YAML data,
|
||||
including strings and other sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
-
|
||||
- foo
|
||||
- bar
|
||||
- x123
|
||||
- banana
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot')
|
||||
---
|
||||
test: Deeply Nested Sequences
|
||||
brief: |
|
||||
Sequences can be nested even deeper, with each
|
||||
level of indentation representing a level of
|
||||
depth.
|
||||
yaml: |
|
||||
-
|
||||
-
|
||||
- uno
|
||||
- dos
|
||||
php: |
|
||||
array(array(array('uno', 'dos')))
|
||||
---
|
||||
test: Simple Mapping
|
||||
brief: |
|
||||
You can add a keyed list (also known as a dictionary or
|
||||
hash) to your document by placing each member of the
|
||||
list on a new line, with a colon separating the key
|
||||
from its value. In YAML, this type of list is called
|
||||
a mapping.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar: stuff
|
||||
php: |
|
||||
array('foo' => 'whatever', 'bar' => 'stuff')
|
||||
---
|
||||
test: Sequence in a Mapping
|
||||
brief: |
|
||||
A value in a mapping can be a sequence.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
- uno
|
||||
- dos
|
||||
php: |
|
||||
array('foo' => 'whatever', 'bar' => array('uno', 'dos'))
|
||||
---
|
||||
test: Nested Mappings
|
||||
brief: |
|
||||
A value in a mapping can be another mapping.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
fruit: apple
|
||||
name: steve
|
||||
sport: baseball
|
||||
php: |
|
||||
array(
|
||||
'foo' => 'whatever',
|
||||
'bar' => array(
|
||||
'fruit' => 'apple',
|
||||
'name' => 'steve',
|
||||
'sport' => 'baseball'
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Mixed Mapping
|
||||
brief: |
|
||||
A mapping can contain any assortment
|
||||
of mappings and sequences as values.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
-
|
||||
fruit: apple
|
||||
name: steve
|
||||
sport: baseball
|
||||
- more
|
||||
-
|
||||
python: rocks
|
||||
perl: papers
|
||||
ruby: scissorses
|
||||
php: |
|
||||
array(
|
||||
'foo' => 'whatever',
|
||||
'bar' => array(
|
||||
array(
|
||||
'fruit' => 'apple',
|
||||
'name' => 'steve',
|
||||
'sport' => 'baseball'
|
||||
),
|
||||
'more',
|
||||
array(
|
||||
'python' => 'rocks',
|
||||
'perl' => 'papers',
|
||||
'ruby' => 'scissorses'
|
||||
)
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Mapping-in-Sequence Shortcut
|
||||
todo: true
|
||||
brief: |
|
||||
If you are adding a mapping to a sequence, you
|
||||
can place the mapping on the same line as the
|
||||
dash as a shortcut.
|
||||
yaml: |
|
||||
- work on YAML.py:
|
||||
- work on Store
|
||||
php: |
|
||||
array(array('work on YAML.py' => array('work on Store')))
|
||||
---
|
||||
test: Sequence-in-Mapping Shortcut
|
||||
todo: true
|
||||
brief: |
|
||||
The dash in a sequence counts as indentation, so
|
||||
you can add a sequence inside of a mapping without
|
||||
needing spaces as indentation.
|
||||
yaml: |
|
||||
allow:
|
||||
- 'localhost'
|
||||
- '%.sourceforge.net'
|
||||
- '%.freepan.org'
|
||||
php: |
|
||||
array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org'))
|
||||
---
|
||||
todo: true
|
||||
test: Merge key
|
||||
brief: |
|
||||
A merge key ('<<') can be used in a mapping to insert other mappings. If
|
||||
the value associated with the merge key is a mapping, each of its key/value
|
||||
pairs is inserted into the current mapping.
|
||||
yaml: |
|
||||
mapping:
|
||||
name: Joe
|
||||
job: Accountant
|
||||
<<:
|
||||
age: 38
|
||||
php: |
|
||||
array(
|
||||
'mapping' =>
|
||||
array(
|
||||
'name' => 'Joe',
|
||||
'job' => 'Accountant',
|
||||
'age' => 38
|
||||
)
|
||||
)
|
51
vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml
vendored
Normal file
51
vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
test: One Element Mapping
|
||||
brief: |
|
||||
A mapping with one key/value pair
|
||||
yaml: |
|
||||
foo: bar
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Multi Element Mapping
|
||||
brief: |
|
||||
More than one key/value pair
|
||||
yaml: |
|
||||
red: baron
|
||||
white: walls
|
||||
blue: berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
||||
---
|
||||
test: Values aligned
|
||||
brief: |
|
||||
Often times human editors of documents will align the values even
|
||||
though YAML emitters generally don't.
|
||||
yaml: |
|
||||
red: baron
|
||||
white: walls
|
||||
blue: berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
||||
---
|
||||
test: Colons aligned
|
||||
brief: |
|
||||
Spaces can come before the ': ' key/value separator.
|
||||
yaml: |
|
||||
red : baron
|
||||
white : walls
|
||||
blue : berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
85
vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml
vendored
Normal file
85
vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
--- %YAML:1.0
|
||||
test: Trailing Document Separator
|
||||
todo: true
|
||||
brief: >
|
||||
You can separate YAML documents
|
||||
with a string of three dashes.
|
||||
yaml: |
|
||||
- foo: 1
|
||||
bar: 2
|
||||
---
|
||||
more: stuff
|
||||
python: |
|
||||
[
|
||||
[ { 'foo': 1, 'bar': 2 } ],
|
||||
{ 'more': 'stuff' }
|
||||
]
|
||||
ruby: |
|
||||
[ { 'foo' => 1, 'bar' => 2 } ]
|
||||
|
||||
---
|
||||
test: Leading Document Separator
|
||||
todo: true
|
||||
brief: >
|
||||
You can explicitly give an opening
|
||||
document separator to your YAML stream.
|
||||
yaml: |
|
||||
---
|
||||
- foo: 1
|
||||
bar: 2
|
||||
---
|
||||
more: stuff
|
||||
python: |
|
||||
[
|
||||
[ {'foo': 1, 'bar': 2}],
|
||||
{'more': 'stuff'}
|
||||
]
|
||||
ruby: |
|
||||
[ { 'foo' => 1, 'bar' => 2 } ]
|
||||
|
||||
---
|
||||
test: YAML Header
|
||||
todo: true
|
||||
brief: >
|
||||
The opening separator can contain directives
|
||||
to the YAML parser, such as the version
|
||||
number.
|
||||
yaml: |
|
||||
--- %YAML:1.0
|
||||
foo: 1
|
||||
bar: 2
|
||||
php: |
|
||||
array('foo' => 1, 'bar' => 2)
|
||||
documents: 1
|
||||
|
||||
---
|
||||
test: Red Herring Document Separator
|
||||
brief: >
|
||||
Separators included in blocks or strings
|
||||
are treated as blocks or strings, as the
|
||||
document separator should have no indentation
|
||||
preceding it.
|
||||
yaml: |
|
||||
foo: |
|
||||
---
|
||||
php: |
|
||||
array('foo' => "---\n")
|
||||
|
||||
---
|
||||
test: Multiple Document Separators in Block
|
||||
brief: >
|
||||
This technique allows you to embed other YAML
|
||||
documents within literal blocks.
|
||||
yaml: |
|
||||
foo: |
|
||||
---
|
||||
foo: bar
|
||||
---
|
||||
yo: baz
|
||||
bar: |
|
||||
fooness
|
||||
php: |
|
||||
array(
|
||||
'foo' => "---\nfoo: bar\n---\nyo: baz\n",
|
||||
'bar' => "fooness\n"
|
||||
)
|
25
vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml
vendored
Normal file
25
vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
test: Missing value for hash item
|
||||
todo: true
|
||||
brief: |
|
||||
Third item in this hash doesn't have a value
|
||||
yaml: |
|
||||
okay: value
|
||||
also okay: ~
|
||||
causes error because no value specified
|
||||
last key: value okay here too
|
||||
python-error: causes error because no value specified
|
||||
|
||||
---
|
||||
test: Not indenting enough
|
||||
brief: |
|
||||
There was a bug in PyYaml where it was off by one
|
||||
in the indentation check. It was allowing the YAML
|
||||
below.
|
||||
# This is actually valid YAML now. Someone should tell showell.
|
||||
yaml: |
|
||||
foo:
|
||||
firstline: 1
|
||||
secondline: 2
|
||||
php: |
|
||||
array('foo' => null, 'firstline' => 1, 'secondline' => 2)
|
60
vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml
vendored
Normal file
60
vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
test: Simple Inline Array
|
||||
brief: >
|
||||
Sequences can be contained on a
|
||||
single line, using the inline syntax.
|
||||
Separate each entry with commas and
|
||||
enclose in square brackets.
|
||||
yaml: |
|
||||
seq: [ a, b, c ]
|
||||
php: |
|
||||
array('seq' => array('a', 'b', 'c'))
|
||||
---
|
||||
test: Simple Inline Hash
|
||||
brief: >
|
||||
Mapping can also be contained on
|
||||
a single line, using the inline
|
||||
syntax. Each key-value pair is
|
||||
separated by a colon, with a comma
|
||||
between each entry in the mapping.
|
||||
Enclose with curly braces.
|
||||
yaml: |
|
||||
hash: { name: Steve, foo: bar }
|
||||
php: |
|
||||
array('hash' => array('name' => 'Steve', 'foo' => 'bar'))
|
||||
---
|
||||
test: Multi-line Inline Collections
|
||||
todo: true
|
||||
brief: >
|
||||
Both inline sequences and inline mappings
|
||||
can span multiple lines, provided that you
|
||||
indent the additional lines.
|
||||
yaml: |
|
||||
languages: [ Ruby,
|
||||
Perl,
|
||||
Python ]
|
||||
websites: { YAML: yaml.org,
|
||||
Ruby: ruby-lang.org,
|
||||
Python: python.org,
|
||||
Perl: use.perl.org }
|
||||
php: |
|
||||
array(
|
||||
'languages' => array('Ruby', 'Perl', 'Python'),
|
||||
'websites' => array(
|
||||
'YAML' => 'yaml.org',
|
||||
'Ruby' => 'ruby-lang.org',
|
||||
'Python' => 'python.org',
|
||||
'Perl' => 'use.perl.org'
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Commas in Values (not in the spec!)
|
||||
todo: true
|
||||
brief: >
|
||||
List items in collections are delimited by commas, but
|
||||
there must be a space after each comma. This allows you
|
||||
to add numbers without quoting.
|
||||
yaml: |
|
||||
attendances: [ 45,123, 70,000, 17,222 ]
|
||||
php: |
|
||||
array('attendances' => array(45123, 70000, 17222))
|
176
vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml
vendored
Normal file
176
vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
--- %YAML:1.0
|
||||
test: Single ending newline
|
||||
brief: >
|
||||
A pipe character, followed by an indented
|
||||
block of text is treated as a literal
|
||||
block, in which newlines are preserved
|
||||
throughout the block, including the final
|
||||
newline.
|
||||
yaml: |
|
||||
---
|
||||
this: |
|
||||
Foo
|
||||
Bar
|
||||
php: |
|
||||
array('this' => "Foo\nBar\n")
|
||||
---
|
||||
test: The '+' indicator
|
||||
brief: >
|
||||
The '+' indicator says to keep newlines at the end of text
|
||||
blocks.
|
||||
yaml: |
|
||||
normal: |
|
||||
extra new lines not kept
|
||||
|
||||
preserving: |+
|
||||
extra new lines are kept
|
||||
|
||||
|
||||
dummy: value
|
||||
php: |
|
||||
array(
|
||||
'normal' => "extra new lines not kept\n",
|
||||
'preserving' => "extra new lines are kept\n\n\n",
|
||||
'dummy' => 'value'
|
||||
)
|
||||
---
|
||||
test: Three trailing newlines in literals
|
||||
brief: >
|
||||
To give you more control over how space
|
||||
is preserved in text blocks, YAML has
|
||||
the keep '+' and chomp '-' indicators.
|
||||
The keep indicator will preserve all
|
||||
ending newlines, while the chomp indicator
|
||||
will strip all ending newlines.
|
||||
yaml: |
|
||||
clipped: |
|
||||
This has one newline.
|
||||
|
||||
|
||||
|
||||
same as "clipped" above: "This has one newline.\n"
|
||||
|
||||
stripped: |-
|
||||
This has no newline.
|
||||
|
||||
|
||||
|
||||
same as "stripped" above: "This has no newline."
|
||||
|
||||
kept: |+
|
||||
This has four newlines.
|
||||
|
||||
|
||||
|
||||
same as "kept" above: "This has four newlines.\n\n\n\n"
|
||||
php: |
|
||||
array(
|
||||
'clipped' => "This has one newline.\n",
|
||||
'same as "clipped" above' => "This has one newline.\n",
|
||||
'stripped' => 'This has no newline.',
|
||||
'same as "stripped" above' => 'This has no newline.',
|
||||
'kept' => "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above' => "This has four newlines.\n\n\n\n"
|
||||
)
|
||||
---
|
||||
test: Extra trailing newlines with spaces
|
||||
todo: true
|
||||
brief: >
|
||||
Normally, only a single newline is kept
|
||||
from the end of a literal block, unless the
|
||||
keep '+' character is used in combination
|
||||
with the pipe. The following example
|
||||
will preserve all ending whitespace
|
||||
since the last line of both literal blocks
|
||||
contains spaces which extend past the indentation
|
||||
level.
|
||||
yaml: |
|
||||
---
|
||||
this: |
|
||||
Foo
|
||||
|
||||
|
||||
kept: |+
|
||||
Foo
|
||||
|
||||
|
||||
php: |
|
||||
array('this' => "Foo\n\n \n",
|
||||
'kept' => "Foo\n\n \n" )
|
||||
|
||||
---
|
||||
test: Folded Block in a Sequence
|
||||
brief: >
|
||||
A greater-then character, followed by an indented
|
||||
block of text is treated as a folded block, in
|
||||
which lines of text separated by a single newline
|
||||
are concatenated as a single line.
|
||||
yaml: |
|
||||
---
|
||||
- apple
|
||||
- banana
|
||||
- >
|
||||
can't you see
|
||||
the beauty of yaml?
|
||||
hmm
|
||||
- dog
|
||||
php: |
|
||||
array(
|
||||
'apple',
|
||||
'banana',
|
||||
"can't you see the beauty of yaml? hmm\n",
|
||||
'dog'
|
||||
)
|
||||
---
|
||||
test: Folded Block as a Mapping Value
|
||||
brief: >
|
||||
Both literal and folded blocks can be
|
||||
used in collections, as values in a
|
||||
sequence or a mapping.
|
||||
yaml: |
|
||||
---
|
||||
quote: >
|
||||
Mark McGwire's
|
||||
year was crippled
|
||||
by a knee injury.
|
||||
source: espn
|
||||
php: |
|
||||
array(
|
||||
'quote' => "Mark McGwire's year was crippled by a knee injury.\n",
|
||||
'source' => 'espn'
|
||||
)
|
||||
---
|
||||
test: Three trailing newlines in folded blocks
|
||||
brief: >
|
||||
The keep and chomp indicators can also
|
||||
be applied to folded blocks.
|
||||
yaml: |
|
||||
clipped: >
|
||||
This has one newline.
|
||||
|
||||
|
||||
|
||||
same as "clipped" above: "This has one newline.\n"
|
||||
|
||||
stripped: >-
|
||||
This has no newline.
|
||||
|
||||
|
||||
|
||||
same as "stripped" above: "This has no newline."
|
||||
|
||||
kept: >+
|
||||
This has four newlines.
|
||||
|
||||
|
||||
|
||||
same as "kept" above: "This has four newlines.\n\n\n\n"
|
||||
php: |
|
||||
array(
|
||||
'clipped' => "This has one newline.\n",
|
||||
'same as "clipped" above' => "This has one newline.\n",
|
||||
'stripped' => 'This has no newline.',
|
||||
'same as "stripped" above' => 'This has no newline.',
|
||||
'kept' => "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above' => "This has four newlines.\n\n\n\n"
|
||||
)
|
45
vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml
vendored
Normal file
45
vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
--- %YAML:1.0
|
||||
test: Empty Sequence
|
||||
brief: >
|
||||
You can represent the empty sequence
|
||||
with an empty inline sequence.
|
||||
yaml: |
|
||||
empty: []
|
||||
php: |
|
||||
array('empty' => array())
|
||||
---
|
||||
test: Empty Mapping
|
||||
brief: >
|
||||
You can represent the empty mapping
|
||||
with an empty inline mapping.
|
||||
yaml: |
|
||||
empty: {}
|
||||
php: |
|
||||
array('empty' => array())
|
||||
---
|
||||
test: Empty Sequence as Entire Document
|
||||
yaml: |
|
||||
[]
|
||||
php: |
|
||||
array()
|
||||
---
|
||||
test: Empty Mapping as Entire Document
|
||||
yaml: |
|
||||
{}
|
||||
php: |
|
||||
array()
|
||||
---
|
||||
test: Null as Document
|
||||
yaml: |
|
||||
~
|
||||
php: |
|
||||
null
|
||||
---
|
||||
test: Empty String
|
||||
brief: >
|
||||
You can represent an empty string
|
||||
with a pair of quotes.
|
||||
yaml: |
|
||||
''
|
||||
php: |
|
||||
''
|
1701
vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml
vendored
Normal file
1701
vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
266
vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml
vendored
Normal file
266
vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml
vendored
Normal file
|
@ -0,0 +1,266 @@
|
|||
--- %YAML:1.0
|
||||
test: Strings
|
||||
brief: >
|
||||
Any group of characters beginning with an
|
||||
alphabetic or numeric character is a string,
|
||||
unless it belongs to one of the groups below
|
||||
(such as an Integer or Time).
|
||||
yaml: |
|
||||
String
|
||||
php: |
|
||||
'String'
|
||||
---
|
||||
test: String characters
|
||||
brief: >
|
||||
A string can contain any alphabetic or
|
||||
numeric character, along with many
|
||||
punctuation characters, including the
|
||||
period, dash, space, quotes, exclamation, and
|
||||
question mark.
|
||||
yaml: |
|
||||
- What's Yaml?
|
||||
- It's for writing data structures in plain text.
|
||||
- And?
|
||||
- And what? That's not good enough for you?
|
||||
- No, I mean, "And what about Yaml?"
|
||||
- Oh, oh yeah. Uh.. Yaml for Ruby.
|
||||
php: |
|
||||
array(
|
||||
"What's Yaml?",
|
||||
"It's for writing data structures in plain text.",
|
||||
"And?",
|
||||
"And what? That's not good enough for you?",
|
||||
"No, I mean, \"And what about Yaml?\"",
|
||||
"Oh, oh yeah. Uh.. Yaml for Ruby."
|
||||
)
|
||||
---
|
||||
test: Indicators in Strings
|
||||
brief: >
|
||||
Be careful using indicators in strings. In particular,
|
||||
the comma, colon, and pound sign must be used carefully.
|
||||
yaml: |
|
||||
the colon followed by space is an indicator: but is a string:right here
|
||||
same for the pound sign: here we have it#in a string
|
||||
the comma can, honestly, be used in most cases: [ but not in, inline collections ]
|
||||
php: |
|
||||
array(
|
||||
'the colon followed by space is an indicator' => 'but is a string:right here',
|
||||
'same for the pound sign' => 'here we have it#in a string',
|
||||
'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections')
|
||||
)
|
||||
---
|
||||
test: Forcing Strings
|
||||
brief: >
|
||||
Any YAML type can be forced into a string using the
|
||||
explicit !!str method.
|
||||
yaml: |
|
||||
date string: !!str 2001-08-01
|
||||
number string: !!str 192
|
||||
php: |
|
||||
array(
|
||||
'date string' => '2001-08-01',
|
||||
'number string' => '192'
|
||||
)
|
||||
---
|
||||
test: Single-quoted Strings
|
||||
brief: >
|
||||
You can also enclose your strings within single quotes,
|
||||
which allows use of slashes, colons, and other indicators
|
||||
freely. Inside single quotes, you can represent a single
|
||||
quote in your string by using two single quotes next to
|
||||
each other.
|
||||
yaml: |
|
||||
all my favorite symbols: '#:!/%.)'
|
||||
a few i hate: '&(*'
|
||||
why do i hate them?: 'it''s very hard to explain'
|
||||
entities: '£ me'
|
||||
php: |
|
||||
array(
|
||||
'all my favorite symbols' => '#:!/%.)',
|
||||
'a few i hate' => '&(*',
|
||||
'why do i hate them?' => 'it\'s very hard to explain',
|
||||
'entities' => '£ me'
|
||||
)
|
||||
---
|
||||
test: Double-quoted Strings
|
||||
brief: >
|
||||
Enclosing strings in double quotes allows you
|
||||
to use escapings to represent ASCII and
|
||||
Unicode characters.
|
||||
yaml: |
|
||||
i know where i want my line breaks: "one here\nand another here\n"
|
||||
php: |
|
||||
array(
|
||||
'i know where i want my line breaks' => "one here\nand another here\n"
|
||||
)
|
||||
---
|
||||
test: Multi-line Quoted Strings
|
||||
todo: true
|
||||
brief: >
|
||||
Both single- and double-quoted strings may be
|
||||
carried on to new lines in your YAML document.
|
||||
They must be indented a step and indentation
|
||||
is interpreted as a single space.
|
||||
yaml: |
|
||||
i want a long string: "so i'm going to
|
||||
let it go on and on to other lines
|
||||
until i end it with a quote."
|
||||
php: |
|
||||
array('i want a long string' => "so i'm going to ".
|
||||
"let it go on and on to other lines ".
|
||||
"until i end it with a quote."
|
||||
)
|
||||
|
||||
---
|
||||
test: Plain scalars
|
||||
todo: true
|
||||
brief: >
|
||||
Unquoted strings may also span multiple lines, if they
|
||||
are free of YAML space indicators and indented.
|
||||
yaml: |
|
||||
- My little toe is broken in two places;
|
||||
- I'm crazy to have skied this way;
|
||||
- I'm not the craziest he's seen, since there was always the German guy
|
||||
who skied for 3 hours on a broken shin bone (just below the kneecap);
|
||||
- Nevertheless, second place is respectable, and he doesn't
|
||||
recommend going for the record;
|
||||
- He's going to put my foot in plaster for a month;
|
||||
- This would impair my skiing ability somewhat for the
|
||||
duration, as can be imagined.
|
||||
php: |
|
||||
array(
|
||||
"My little toe is broken in two places;",
|
||||
"I'm crazy to have skied this way;",
|
||||
"I'm not the craziest he's seen, since there was always ".
|
||||
"the German guy who skied for 3 hours on a broken shin ".
|
||||
"bone (just below the kneecap);",
|
||||
"Nevertheless, second place is respectable, and he doesn't ".
|
||||
"recommend going for the record;",
|
||||
"He's going to put my foot in plaster for a month;",
|
||||
"This would impair my skiing ability somewhat for the duration, ".
|
||||
"as can be imagined."
|
||||
)
|
||||
---
|
||||
test: 'Null'
|
||||
brief: >
|
||||
You can use the tilde '~' character for a null value.
|
||||
yaml: |
|
||||
name: Mr. Show
|
||||
hosted by: Bob and David
|
||||
date of next season: ~
|
||||
php: |
|
||||
array(
|
||||
'name' => 'Mr. Show',
|
||||
'hosted by' => 'Bob and David',
|
||||
'date of next season' => null
|
||||
)
|
||||
---
|
||||
test: Boolean
|
||||
brief: >
|
||||
You can use 'true' and 'false' for Boolean values.
|
||||
yaml: |
|
||||
Is Gus a Liar?: true
|
||||
Do I rely on Gus for Sustenance?: false
|
||||
php: |
|
||||
array(
|
||||
'Is Gus a Liar?' => true,
|
||||
'Do I rely on Gus for Sustenance?' => false
|
||||
)
|
||||
---
|
||||
test: Integers
|
||||
dump_skip: true
|
||||
brief: >
|
||||
An integer is a series of numbers, optionally
|
||||
starting with a positive or negative sign. Integers
|
||||
may also contain commas for readability.
|
||||
yaml: |
|
||||
zero: 0
|
||||
simple: 12
|
||||
php: |
|
||||
array(
|
||||
'zero' => 0,
|
||||
'simple' => 12,
|
||||
)
|
||||
---
|
||||
test: Positive Big Integer
|
||||
deprecated: true
|
||||
dump_skip: true
|
||||
brief: >
|
||||
An integer is a series of numbers, optionally
|
||||
starting with a positive or negative sign. Integers
|
||||
may also contain commas for readability.
|
||||
yaml: |
|
||||
one-thousand: 1,000
|
||||
php: |
|
||||
array(
|
||||
'one-thousand' => 1000.0,
|
||||
)
|
||||
---
|
||||
test: Negative Big Integer
|
||||
deprecated: true
|
||||
dump_skip: true
|
||||
brief: >
|
||||
An integer is a series of numbers, optionally
|
||||
starting with a positive or negative sign. Integers
|
||||
may also contain commas for readability.
|
||||
yaml: |
|
||||
negative one-thousand: -1,000
|
||||
php: |
|
||||
array(
|
||||
'negative one-thousand' => -1000.0
|
||||
)
|
||||
---
|
||||
test: Floats
|
||||
dump_skip: true
|
||||
brief: >
|
||||
Floats are represented by numbers with decimals,
|
||||
allowing for scientific notation, as well as
|
||||
positive and negative infinity and "not a number."
|
||||
yaml: |
|
||||
a simple float: 2.00
|
||||
scientific notation: 1.00009e+3
|
||||
php: |
|
||||
array(
|
||||
'a simple float' => 2.0,
|
||||
'scientific notation' => 1000.09
|
||||
)
|
||||
---
|
||||
test: Larger Float
|
||||
dump_skip: true
|
||||
deprecated: true
|
||||
brief: >
|
||||
Floats are represented by numbers with decimals,
|
||||
allowing for scientific notation, as well as
|
||||
positive and negative infinity and "not a number."
|
||||
yaml: |
|
||||
larger float: 1,000.09
|
||||
php: |
|
||||
array(
|
||||
'larger float' => 1000.09,
|
||||
)
|
||||
---
|
||||
test: Time
|
||||
todo: true
|
||||
brief: >
|
||||
You can represent timestamps by using
|
||||
ISO8601 format, or a variation which
|
||||
allows spaces between the date, time and
|
||||
time zone.
|
||||
yaml: |
|
||||
iso8601: 2001-12-14t21:59:43.10-05:00
|
||||
space separated: 2001-12-14 21:59:43.10 -05:00
|
||||
php: |
|
||||
array(
|
||||
'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
||||
'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" )
|
||||
)
|
||||
---
|
||||
test: Date
|
||||
todo: true
|
||||
brief: >
|
||||
A date can be represented by its year,
|
||||
month and day in ISO8601 order.
|
||||
yaml: |
|
||||
1976-07-31
|
||||
php: |
|
||||
date( 1976, 7, 31 )
|
BIN
vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
Normal file
BIN
vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 B |
11
vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml
vendored
Normal file
11
vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
true: true
|
||||
false: false
|
||||
php: |
|
||||
array(
|
||||
'true' => true,
|
||||
'false' => false,
|
||||
)
|
1
vendor/symfony/yaml/Tests/Fixtures/embededPhp.yml
vendored
Normal file
1
vendor/symfony/yaml/Tests/Fixtures/embededPhp.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
value: <?php echo 1 + 2 + 3 ?>
|
155
vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml
vendored
Normal file
155
vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
test: outside double quotes
|
||||
yaml: |
|
||||
\0 \ \a \b \n
|
||||
php: |
|
||||
"\\0 \\ \\a \\b \\n"
|
||||
---
|
||||
test: null
|
||||
yaml: |
|
||||
"\0"
|
||||
php: |
|
||||
"\x00"
|
||||
---
|
||||
test: bell
|
||||
yaml: |
|
||||
"\a"
|
||||
php: |
|
||||
"\x07"
|
||||
---
|
||||
test: backspace
|
||||
yaml: |
|
||||
"\b"
|
||||
php: |
|
||||
"\x08"
|
||||
---
|
||||
test: horizontal tab (1)
|
||||
yaml: |
|
||||
"\t"
|
||||
php: |
|
||||
"\x09"
|
||||
---
|
||||
test: horizontal tab (2)
|
||||
yaml: |
|
||||
"\ "
|
||||
php: |
|
||||
"\x09"
|
||||
---
|
||||
test: line feed
|
||||
yaml: |
|
||||
"\n"
|
||||
php: |
|
||||
"\x0a"
|
||||
---
|
||||
test: vertical tab
|
||||
yaml: |
|
||||
"\v"
|
||||
php: |
|
||||
"\x0b"
|
||||
---
|
||||
test: form feed
|
||||
yaml: |
|
||||
"\f"
|
||||
php: |
|
||||
"\x0c"
|
||||
---
|
||||
test: carriage return
|
||||
yaml: |
|
||||
"\r"
|
||||
php: |
|
||||
"\x0d"
|
||||
---
|
||||
test: escape
|
||||
yaml: |
|
||||
"\e"
|
||||
php: |
|
||||
"\x1b"
|
||||
---
|
||||
test: space
|
||||
yaml: |
|
||||
"\ "
|
||||
php: |
|
||||
"\x20"
|
||||
---
|
||||
test: slash
|
||||
yaml: |
|
||||
"\/"
|
||||
php: |
|
||||
"\x2f"
|
||||
---
|
||||
test: backslash
|
||||
yaml: |
|
||||
"\\"
|
||||
php: |
|
||||
"\\"
|
||||
---
|
||||
test: Unicode next line
|
||||
yaml: |
|
||||
"\N"
|
||||
php: |
|
||||
"\xc2\x85"
|
||||
---
|
||||
test: Unicode non-breaking space
|
||||
yaml: |
|
||||
"\_"
|
||||
php: |
|
||||
"\xc2\xa0"
|
||||
---
|
||||
test: Unicode line separator
|
||||
yaml: |
|
||||
"\L"
|
||||
php: |
|
||||
"\xe2\x80\xa8"
|
||||
---
|
||||
test: Unicode paragraph separator
|
||||
yaml: |
|
||||
"\P"
|
||||
php: |
|
||||
"\xe2\x80\xa9"
|
||||
---
|
||||
test: Escaped 8-bit Unicode
|
||||
yaml: |
|
||||
"\x42"
|
||||
php: |
|
||||
"B"
|
||||
---
|
||||
test: Escaped 16-bit Unicode
|
||||
yaml: |
|
||||
"\u20ac"
|
||||
php: |
|
||||
"\xe2\x82\xac"
|
||||
---
|
||||
test: Escaped 32-bit Unicode
|
||||
yaml: |
|
||||
"\U00000043"
|
||||
php: |
|
||||
"C"
|
||||
---
|
||||
test: Example 5.13 Escaped Characters
|
||||
note: |
|
||||
Currently throws an error parsing first line. Maybe Symfony Yaml doesn't support
|
||||
continuation of string across multiple lines? Keeping test here but disabled.
|
||||
todo: true
|
||||
yaml: |
|
||||
"Fun with \\
|
||||
\" \a \b \e \f \
|
||||
\n \r \t \v \0 \
|
||||
\ \_ \N \L \P \
|
||||
\x41 \u0041 \U00000041"
|
||||
php: |
|
||||
"Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A"
|
||||
---
|
||||
test: Double quotes with a line feed
|
||||
yaml: |
|
||||
{ double: "some value\n \"some quoted string\" and 'some single quotes one'" }
|
||||
php: |
|
||||
array(
|
||||
'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
|
||||
)
|
||||
---
|
||||
test: Backslashes
|
||||
yaml: |
|
||||
{ single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" }
|
||||
php: |
|
||||
array(
|
||||
'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var'
|
||||
)
|
18
vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
Normal file
18
vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
- escapedCharacters
|
||||
- sfComments
|
||||
- sfCompact
|
||||
- sfTests
|
||||
- sfObjects
|
||||
- sfMergeKey
|
||||
- sfQuotes
|
||||
- YtsAnchorAlias
|
||||
- YtsBasicTests
|
||||
- YtsBlockMapping
|
||||
- YtsDocumentSeparator
|
||||
- YtsErrorTests
|
||||
- YtsFlowCollections
|
||||
- YtsFoldedScalars
|
||||
- YtsNullsAndEmpties
|
||||
- YtsSpecificationExamples
|
||||
- YtsTypeTransfers
|
||||
- unindentedCollections
|
23
vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml
vendored
Normal file
23
vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
true: true
|
||||
false: false
|
||||
php: |
|
||||
array(
|
||||
1 => true,
|
||||
0 => false,
|
||||
)
|
||||
---
|
||||
test: Boolean
|
||||
yaml: |
|
||||
false: used as key
|
||||
logical: true
|
||||
answer: false
|
||||
php: |
|
||||
array(
|
||||
false => 'used as key',
|
||||
'logical' => true,
|
||||
'answer' => false
|
||||
)
|
2
vendor/symfony/yaml/Tests/Fixtures/legacyNonStringKeys.yml
vendored
Normal file
2
vendor/symfony/yaml/Tests/Fixtures/legacyNonStringKeys.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
- legacyBooleanMappingKeys
|
||||
- legacyNullMappingKey
|
9
vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml
vendored
Normal file
9
vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
null: ~
|
||||
php: |
|
||||
array(
|
||||
'' => null,
|
||||
)
|
13
vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Normal file
13
vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
data:
|
||||
single_line: 'foo bar baz'
|
||||
multi_line: |
|
||||
foo
|
||||
line with trailing spaces:
|
||||
|
||||
bar
|
||||
integer like line:
|
||||
123456789
|
||||
empty line:
|
||||
|
||||
baz
|
||||
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
|
3
vendor/symfony/yaml/Tests/Fixtures/nonStringKeys.yml
vendored
Normal file
3
vendor/symfony/yaml/Tests/Fixtures/nonStringKeys.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
- booleanMappingKeys
|
||||
- numericMappingKeys
|
||||
- nullMappingKey
|
18
vendor/symfony/yaml/Tests/Fixtures/not_readable.yml
vendored
Normal file
18
vendor/symfony/yaml/Tests/Fixtures/not_readable.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
- escapedCharacters
|
||||
- sfComments
|
||||
- sfCompact
|
||||
- sfTests
|
||||
- sfObjects
|
||||
- sfMergeKey
|
||||
- sfQuotes
|
||||
- YtsAnchorAlias
|
||||
- YtsBasicTests
|
||||
- YtsBlockMapping
|
||||
- YtsDocumentSeparator
|
||||
- YtsErrorTests
|
||||
- YtsFlowCollections
|
||||
- YtsFoldedScalars
|
||||
- YtsNullsAndEmpties
|
||||
- YtsSpecificationExamples
|
||||
- YtsTypeTransfers
|
||||
- unindentedCollections
|
9
vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml
vendored
Normal file
9
vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
null: ~
|
||||
php: |
|
||||
array(
|
||||
'null' => null,
|
||||
)
|
23
vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml
vendored
Normal file
23
vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
--- %YAML:1.0
|
||||
test: A sequence with an unordered array
|
||||
brief: >
|
||||
A sequence with an unordered array
|
||||
yaml: |
|
||||
1: foo
|
||||
0: bar
|
||||
php: |
|
||||
array(1 => 'foo', 0 => 'bar')
|
||||
---
|
||||
test: Integers as Map Keys
|
||||
brief: >
|
||||
An integer can be used as dictionary key.
|
||||
yaml: |
|
||||
1: one
|
||||
2: two
|
||||
3: three
|
||||
php: |
|
||||
array(
|
||||
1 => 'one',
|
||||
2 => 'two',
|
||||
3 => 'three'
|
||||
)
|
76
vendor/symfony/yaml/Tests/Fixtures/sfComments.yml
vendored
Normal file
76
vendor/symfony/yaml/Tests/Fixtures/sfComments.yml
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
--- %YAML:1.0
|
||||
test: Comments at the end of a line
|
||||
brief: >
|
||||
Comments at the end of a line
|
||||
yaml: |
|
||||
ex1: "foo # bar"
|
||||
ex2: "foo # bar" # comment
|
||||
ex3: 'foo # bar' # comment
|
||||
ex4: foo # comment
|
||||
ex5: foo # comment with tab before
|
||||
ex6: foo#foo # comment here
|
||||
ex7: foo # ignore me # and me
|
||||
php: |
|
||||
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo', 'ex7' => 'foo')
|
||||
---
|
||||
test: Comments in the middle
|
||||
brief: >
|
||||
Comments in the middle
|
||||
yaml: |
|
||||
foo:
|
||||
# some comment
|
||||
# some comment
|
||||
bar: foo
|
||||
# some comment
|
||||
# some comment
|
||||
php: |
|
||||
array('foo' => array('bar' => 'foo'))
|
||||
---
|
||||
test: Comments on a hash line
|
||||
brief: >
|
||||
Comments on a hash line
|
||||
yaml: |
|
||||
foo: # a comment
|
||||
foo: bar # a comment
|
||||
php: |
|
||||
array('foo' => array('foo' => 'bar'))
|
||||
---
|
||||
test: 'Value starting with a #'
|
||||
brief: >
|
||||
'Value starting with a #'
|
||||
yaml: |
|
||||
foo: '#bar'
|
||||
php: |
|
||||
array('foo' => '#bar')
|
||||
---
|
||||
test: Document starting with a comment and a separator
|
||||
brief: >
|
||||
Commenting before document start is allowed
|
||||
yaml: |
|
||||
# document comment
|
||||
---
|
||||
foo: bar # a comment
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Comment containing a colon on a hash line
|
||||
brief: >
|
||||
Comment containing a colon on a scalar line
|
||||
yaml: 'foo # comment: this is also part of the comment'
|
||||
php: |
|
||||
'foo'
|
||||
---
|
||||
test: 'Hash key containing a #'
|
||||
brief: >
|
||||
'Hash key containing a #'
|
||||
yaml: 'foo#bar: baz'
|
||||
php: |
|
||||
array('foo#bar' => 'baz')
|
||||
---
|
||||
test: 'Hash key ending with a space and a #'
|
||||
brief: >
|
||||
'Hash key ending with a space and a #'
|
||||
yaml: |
|
||||
'foo #': baz
|
||||
php: |
|
||||
array('foo #' => 'baz')
|
159
vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
Normal file
159
vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
||||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
||||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
61
vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml
vendored
Normal file
61
vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
--- %YAML:1.0
|
||||
test: Simple In Place Substitution
|
||||
brief: >
|
||||
If you want to reuse an entire alias, only overwriting what is different
|
||||
you can use a << in place substitution. This is not part of the official
|
||||
YAML spec, but a widely implemented extension. See the following URL for
|
||||
details: http://yaml.org/type/merge.html
|
||||
yaml: |
|
||||
foo: &foo
|
||||
a: Steve
|
||||
b: Clark
|
||||
c: Brian
|
||||
e: notnull
|
||||
bar:
|
||||
a: before
|
||||
d: other
|
||||
e: ~
|
||||
<<: *foo
|
||||
b: new
|
||||
x: Oren
|
||||
c:
|
||||
foo: bar
|
||||
bar: foo
|
||||
bar_inline: {a: before, d: other, <<: *foo, b: new, x: Oren, c: { foo: bar, bar: foo}}
|
||||
foo2: &foo2
|
||||
a: Ballmer
|
||||
ding: &dong [ fi, fei, fo, fam]
|
||||
check:
|
||||
<<:
|
||||
- *foo
|
||||
- *dong
|
||||
isit: tested
|
||||
head:
|
||||
<<: [ *foo , *dong , *foo2 ]
|
||||
taz: &taz
|
||||
a: Steve
|
||||
w:
|
||||
p: 1234
|
||||
nested:
|
||||
<<: *taz
|
||||
d: Doug
|
||||
w: &nestedref
|
||||
p: 12345
|
||||
z:
|
||||
<<: *nestedref
|
||||
head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] }
|
||||
recursive_inline: { <<: *head_inline, c: { <<: *foo2 } }
|
||||
php: |
|
||||
array(
|
||||
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
|
||||
'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
|
||||
'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'),
|
||||
'foo2' => array('a' => 'Ballmer'),
|
||||
'ding' => array('fi', 'fei', 'fo', 'fam'),
|
||||
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
|
||||
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
|
||||
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)),
|
||||
'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
)
|
11
vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
Normal file
11
vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- %YAML:1.0
|
||||
test: Objects
|
||||
brief: >
|
||||
Comments at the end of a line
|
||||
yaml: |
|
||||
ex1: "foo # bar"
|
||||
ex2: "foo # bar" # comment
|
||||
ex3: 'foo # bar' # comment
|
||||
ex4: foo # comment
|
||||
php: |
|
||||
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
|
33
vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
Normal file
33
vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
--- %YAML:1.0
|
||||
test: Some characters at the beginning of a string must be escaped
|
||||
brief: >
|
||||
Some characters at the beginning of a string must be escaped
|
||||
yaml: |
|
||||
foo: '| bar'
|
||||
php: |
|
||||
array('foo' => '| bar')
|
||||
---
|
||||
test: A key can be a quoted string
|
||||
brief: >
|
||||
A key can be a quoted string
|
||||
yaml: |
|
||||
"foo1": bar
|
||||
'foo2': bar
|
||||
"foo \" bar": bar
|
||||
'foo '' bar': bar
|
||||
'foo3: ': bar
|
||||
"foo4: ": bar
|
||||
foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar }
|
||||
php: |
|
||||
array(
|
||||
'foo1' => 'bar',
|
||||
'foo2' => 'bar',
|
||||
'foo " bar' => 'bar',
|
||||
'foo \' bar' => 'bar',
|
||||
'foo3: ' => 'bar',
|
||||
'foo4: ' => 'bar',
|
||||
'foo5' => array(
|
||||
'foo " bar: ' => 'bar',
|
||||
'foo \' bar: ' => 'bar',
|
||||
),
|
||||
)
|
140
vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
Normal file
140
vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
--- %YAML:1.0
|
||||
test: Multiple quoted string on one line
|
||||
brief: >
|
||||
Multiple quoted string on one line
|
||||
yaml: |
|
||||
stripped_title: { name: "foo bar", help: "bar foo" }
|
||||
php: |
|
||||
array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo'))
|
||||
---
|
||||
test: Empty sequence
|
||||
yaml: |
|
||||
foo: [ ]
|
||||
php: |
|
||||
array('foo' => array())
|
||||
---
|
||||
test: Empty value
|
||||
yaml: |
|
||||
foo:
|
||||
php: |
|
||||
array('foo' => null)
|
||||
---
|
||||
test: Inline string parsing
|
||||
brief: >
|
||||
Inline string parsing
|
||||
yaml: |
|
||||
test: ['complex: string', 'another [string]']
|
||||
php: |
|
||||
array('test' => array('complex: string', 'another [string]'))
|
||||
---
|
||||
test: Boolean
|
||||
brief: >
|
||||
Boolean
|
||||
yaml: |
|
||||
- false
|
||||
- true
|
||||
- null
|
||||
- ~
|
||||
- 'false'
|
||||
- 'true'
|
||||
- 'null'
|
||||
- '~'
|
||||
php: |
|
||||
array(
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
'false',
|
||||
'true',
|
||||
'null',
|
||||
'~',
|
||||
)
|
||||
---
|
||||
test: Empty lines in literal blocks
|
||||
brief: >
|
||||
Empty lines in literal blocks
|
||||
yaml: |
|
||||
foo:
|
||||
bar: |
|
||||
foo
|
||||
|
||||
|
||||
|
||||
bar
|
||||
php: |
|
||||
array('foo' => array('bar' => "foo\n\n\n \nbar\n"))
|
||||
---
|
||||
test: Empty lines in folded blocks
|
||||
brief: >
|
||||
Empty lines in folded blocks
|
||||
yaml: |
|
||||
foo:
|
||||
bar: >
|
||||
|
||||
foo
|
||||
|
||||
|
||||
bar
|
||||
php: |
|
||||
array('foo' => array('bar' => "\nfoo\n\nbar\n"))
|
||||
---
|
||||
test: IP addresses
|
||||
brief: >
|
||||
IP addresses
|
||||
yaml: |
|
||||
foo: 10.0.0.2
|
||||
php: |
|
||||
array('foo' => '10.0.0.2')
|
||||
---
|
||||
test: A sequence with an embedded mapping
|
||||
brief: >
|
||||
A sequence with an embedded mapping
|
||||
yaml: |
|
||||
- foo
|
||||
- bar: { bar: foo }
|
||||
php: |
|
||||
array('foo', array('bar' => array('bar' => 'foo')))
|
||||
---
|
||||
test: Octal
|
||||
brief: as in spec example 2.19, octal value is converted
|
||||
yaml: |
|
||||
foo: 0123
|
||||
php: |
|
||||
array('foo' => 83)
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: "0123"
|
||||
php: |
|
||||
array('foo' => '0123')
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: '0123'
|
||||
php: |
|
||||
array('foo' => '0123')
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: |
|
||||
0123
|
||||
php: |
|
||||
array('foo' => "0123\n")
|
||||
---
|
||||
test: Document as a simple hash
|
||||
brief: Document as a simple hash
|
||||
yaml: |
|
||||
{ foo: bar }
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Document as a simple array
|
||||
brief: Document as a simple array
|
||||
yaml: |
|
||||
[ foo, bar ]
|
||||
php: |
|
||||
array('foo', 'bar')
|
82
vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml
vendored
Normal file
82
vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
--- %YAML:1.0
|
||||
test: Unindented collection
|
||||
brief: >
|
||||
Unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- item1
|
||||
- item2
|
||||
- item3
|
||||
php: |
|
||||
array('collection' => array('item1', 'item2', 'item3'))
|
||||
---
|
||||
test: Nested unindented collection (two levels)
|
||||
brief: >
|
||||
Nested unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c')))
|
||||
---
|
||||
test: Nested unindented collection (three levels)
|
||||
brief: >
|
||||
Nested unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
subkey:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
php: |
|
||||
array('collection' => array('key' => array('subkey' => array('one', 'two', 'three'))))
|
||||
---
|
||||
test: Key/value after unindented collection (1)
|
||||
brief: >
|
||||
Key/value after unindented collection (1)
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar')
|
||||
---
|
||||
test: Key/value after unindented collection (at the same level)
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar'))
|
||||
---
|
||||
test: Shortcut Key after unindented collection
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- key: foo
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
|
||||
---
|
||||
test: Shortcut Key after unindented collection with custom spaces
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- key: foo
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
|
807
vendor/symfony/yaml/Tests/InlineTest.php
vendored
Normal file
807
vendor/symfony/yaml/Tests/InlineTest.php
vendored
Normal file
|
@ -0,0 +1,807 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class InlineTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
Inline::initialize(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParse
|
||||
*/
|
||||
public function testParse($yaml, $value, $flags = 0)
|
||||
{
|
||||
$this->assertSame($value, Inline::parse($yaml, $flags), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParseWithMapObjects
|
||||
*/
|
||||
public function testParseWithMapObjects($yaml, $value, $flags = Yaml::PARSE_OBJECT_FOR_MAP)
|
||||
{
|
||||
$actual = Inline::parse($yaml, $flags);
|
||||
|
||||
$this->assertSame(serialize($value), serialize($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParsePhpConstants
|
||||
*/
|
||||
public function testParsePhpConstants($yaml, $value)
|
||||
{
|
||||
$actual = Inline::parse($yaml, Yaml::PARSE_CONSTANT);
|
||||
|
||||
$this->assertSame($value, $actual);
|
||||
}
|
||||
|
||||
public function getTestsForParsePhpConstants()
|
||||
{
|
||||
return array(
|
||||
array('!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
|
||||
array('!php/const PHP_INT_MAX', PHP_INT_MAX),
|
||||
array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)),
|
||||
array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
|
||||
array('!php/const NULL', null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined
|
||||
*/
|
||||
public function testParsePhpConstantThrowsExceptionWhenUndefined()
|
||||
{
|
||||
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#
|
||||
*/
|
||||
public function testParsePhpConstantThrowsExceptionOnInvalidType()
|
||||
{
|
||||
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 1.
|
||||
* @dataProvider getTestsForParseLegacyPhpConstants
|
||||
*/
|
||||
public function testDeprecatedConstantTag($yaml, $expectedValue)
|
||||
{
|
||||
$this->assertSame($expectedValue, Inline::parse($yaml, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
public function getTestsForParseLegacyPhpConstants()
|
||||
{
|
||||
return array(
|
||||
array('!php/const:Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
|
||||
array('!php/const:PHP_INT_MAX', PHP_INT_MAX),
|
||||
array('[!php/const:PHP_INT_MAX]', array(PHP_INT_MAX)),
|
||||
array('{ foo: !php/const:PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
|
||||
array('!php/const:NULL', null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getTestsForParseWithMapObjects
|
||||
*/
|
||||
public function testParseWithMapObjectsPassingTrue($yaml, $value)
|
||||
{
|
||||
$actual = Inline::parse($yaml, false, false, true);
|
||||
|
||||
$this->assertSame(serialize($value), serialize($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForDump
|
||||
*/
|
||||
public function testDump($yaml, $value, $parseFlags = 0)
|
||||
{
|
||||
$this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
|
||||
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value), $parseFlags), 'check consistency');
|
||||
}
|
||||
|
||||
public function testDumpNumericValueWithLocale()
|
||||
{
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false === $locale) {
|
||||
$this->markTestSkipped('Your platform does not support locales.');
|
||||
}
|
||||
|
||||
try {
|
||||
$requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
|
||||
if (false === setlocale(LC_NUMERIC, $requiredLocales)) {
|
||||
$this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales));
|
||||
}
|
||||
|
||||
$this->assertEquals('1.2', Inline::dump(1.2));
|
||||
$this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
|
||||
} finally {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
}
|
||||
}
|
||||
|
||||
public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
|
||||
{
|
||||
$value = '686e444';
|
||||
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Found unknown escape character "\V".
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\Var"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
|
||||
{
|
||||
$value = "'don't do somthin' like that'";
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
|
||||
{
|
||||
$value = '"don"t do somthin" like that"';
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidMappingKeyShouldThrowException()
|
||||
{
|
||||
$value = '{ "foo " bar": "bar" }';
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0 on line 1.
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseMappingKeyWithColonNotFollowedBySpace()
|
||||
{
|
||||
Inline::parse('{1:""}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidMappingShouldThrowException()
|
||||
{
|
||||
Inline::parse('[foo] bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidSequenceShouldThrowException()
|
||||
{
|
||||
Inline::parse('{ foo: bar } bar');
|
||||
}
|
||||
|
||||
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
|
||||
{
|
||||
$value = "'don''t do somthin'' like that'";
|
||||
$expect = "don't do somthin' like that";
|
||||
|
||||
$this->assertSame($expect, Inline::parseScalar($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDataForParseReferences
|
||||
*/
|
||||
public function testParseReferences($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml, 0, array('var' => 'var-value')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getDataForParseReferences
|
||||
*/
|
||||
public function testParseReferencesAsFifthArgument($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml, false, false, false, array('var' => 'var-value')));
|
||||
}
|
||||
|
||||
public function getDataForParseReferences()
|
||||
{
|
||||
return array(
|
||||
'scalar' => array('*var', 'var-value'),
|
||||
'list' => array('[ *var ]', array('var-value')),
|
||||
'list-in-list' => array('[[ *var ]]', array(array('var-value'))),
|
||||
'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))),
|
||||
'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))),
|
||||
'map' => array('{ key: *var }', array('key' => 'var-value')),
|
||||
'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))),
|
||||
'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function testParseMapReferenceInSequence()
|
||||
{
|
||||
$foo = array(
|
||||
'a' => 'Steve',
|
||||
'b' => 'Clark',
|
||||
'c' => 'Brian',
|
||||
);
|
||||
$this->assertSame(array($foo), Inline::parse('[*foo]', 0, array('foo' => $foo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testParseMapReferenceInSequenceAsFifthArgument()
|
||||
{
|
||||
$foo = array(
|
||||
'a' => 'Steve',
|
||||
'b' => 'Clark',
|
||||
'c' => 'Brian',
|
||||
);
|
||||
$this->assertSame(array($foo), Inline::parse('[*foo]', false, false, false, array('foo' => $foo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsterisk()
|
||||
{
|
||||
Inline::parse('{ foo: * }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsteriskFollowedByAComment()
|
||||
{
|
||||
Inline::parse('{ foo: * #foo }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReservedIndicators
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
||||
}
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getReservedIndicators()
|
||||
{
|
||||
return array(array('@'), array('`'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getScalarIndicators
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
||||
}
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getScalarIndicators()
|
||||
{
|
||||
return array(array('|'), array('>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0 on line 1.
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithPercentCharacter()
|
||||
{
|
||||
Inline::parse('{ foo: %bar }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDataForIsHash
|
||||
*/
|
||||
public function testIsHash($array, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::isHash($array));
|
||||
}
|
||||
|
||||
public function getDataForIsHash()
|
||||
{
|
||||
return array(
|
||||
array(array(), false),
|
||||
array(array(1, 2, 3), false),
|
||||
array(array(2 => 1, 1 => 2, 0 => 3), true),
|
||||
array(array('foo' => 1, 'bar' => 2), true),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForParse()
|
||||
{
|
||||
return array(
|
||||
array('', ''),
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array('-12', -12),
|
||||
array('1_2', 12),
|
||||
array('_12', '_12'),
|
||||
array('12_', 12),
|
||||
array('"quoted string"', 'quoted string'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('12.30e+02', 12.30e+02),
|
||||
array('123.45_67', 123.4567),
|
||||
array('0x4D2', 0x4D2),
|
||||
array('0x_4_D_2_', 0x4D2),
|
||||
array('02333', 02333),
|
||||
array('0_2_3_3_3', 02333),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('686e444', 646e444),
|
||||
array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
array('::form_base.html.twig', '::form_base.html.twig'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
|
||||
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
|
||||
array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
|
||||
|
||||
array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
// sequences
|
||||
// urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
|
||||
array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
|
||||
array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{foo: bar,bar: foo,"false": false, "null": null,integer: 12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
|
||||
array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
|
||||
array('{"foo:bar": "baz"}', array('foo:bar' => 'baz')),
|
||||
array('{"foo":"bar"}', array('foo' => 'bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))),
|
||||
array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))),
|
||||
array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))),
|
||||
array('{ foo:{bar: foo} }', array('foo' => array('bar' => 'foo'))),
|
||||
array('{ foo:[bar, foo] }', array('foo' => array('bar', 'foo'))),
|
||||
|
||||
array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))),
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForParseWithMapObjects()
|
||||
{
|
||||
return array(
|
||||
array('', ''),
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array('-12', -12),
|
||||
array('"quoted string"', 'quoted string'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('12.30e+02', 12.30e+02),
|
||||
array('0x4D2', 0x4D2),
|
||||
array('02333', 02333),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('686e444', 646e444),
|
||||
array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
array('::form_base.html.twig', '::form_base.html.twig'),
|
||||
|
||||
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
|
||||
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
|
||||
array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
|
||||
|
||||
array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
// sequences
|
||||
// urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
|
||||
array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
|
||||
array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
|
||||
array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
|
||||
array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
|
||||
array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
|
||||
array('{"foo:bar": "baz"}', (object) array('foo:bar' => 'baz')),
|
||||
array('{"foo":"bar"}', (object) array('foo' => 'bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))),
|
||||
array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))),
|
||||
array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))),
|
||||
|
||||
array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))),
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
|
||||
array('{}', new \stdClass()),
|
||||
array('{ foo : bar, bar : {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{ foo : [], bar : {} }', (object) array('foo' => array(), 'bar' => new \stdClass())),
|
||||
array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')),
|
||||
|
||||
array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))),
|
||||
array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))),
|
||||
array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))),
|
||||
array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForDump()
|
||||
{
|
||||
return array(
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array("'1_2'", '1_2'),
|
||||
array('_12', '_12'),
|
||||
array("'12_'", '12_'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('!!float 1230', 12.30e+02),
|
||||
array('1234', 0x4D2),
|
||||
array('1243', 02333),
|
||||
array("'0x_4_D_2_'", '0x_4_D_2_'),
|
||||
array("'0_2_3_3_3'", '0_2_3_3_3'),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
array("'-dash'", '-dash'),
|
||||
array("'-'", '-'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
// sequences
|
||||
array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))),
|
||||
|
||||
array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))),
|
||||
|
||||
array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
|
||||
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseTimestampAsUnixTimestampByDefault($yaml, $year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$this->assertSame(gmmktime($hour, $minute, $second, $month, $day, $year), Inline::parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second, $timezone)
|
||||
{
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
|
||||
if (\PHP_VERSION_ID >= 70100) {
|
||||
$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
} else {
|
||||
$expected->setTime($hour, $minute, $second);
|
||||
}
|
||||
|
||||
$date = Inline::parse($yaml, Yaml::PARSE_DATETIME);
|
||||
$this->assertEquals($expected, $date);
|
||||
$this->assertSame($timezone, $date->format('O'));
|
||||
}
|
||||
|
||||
public function getTimestampTests()
|
||||
{
|
||||
return array(
|
||||
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1, '+0000'),
|
||||
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1, '-0500'),
|
||||
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1, '-0500'),
|
||||
'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0, '+0000'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
if (\PHP_VERSION_ID >= 70100) {
|
||||
$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
} else {
|
||||
$expected->setTime($hour, $minute, $second);
|
||||
}
|
||||
|
||||
$expectedNested = array('nested' => array($expected));
|
||||
$yamlNested = "{nested: [$yaml]}";
|
||||
|
||||
$this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDateTimeDumpTests
|
||||
*/
|
||||
public function testDumpDateTime($dateTime, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::dump($dateTime));
|
||||
}
|
||||
|
||||
public function getDateTimeDumpTests()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$dateTime = new \DateTime('2001-12-15 21:59:43', new \DateTimeZone('UTC'));
|
||||
$tests['date-time-utc'] = array($dateTime, '2001-12-15T21:59:43+00:00');
|
||||
|
||||
$dateTime = new \DateTimeImmutable('2001-07-15 21:59:43', new \DateTimeZone('Europe/Berlin'));
|
||||
$tests['immutable-date-time-europe-berlin'] = array($dateTime, '2001-07-15T21:59:43+02:00');
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getBinaryData
|
||||
*/
|
||||
public function testParseBinaryData($data)
|
||||
{
|
||||
$this->assertSame('Hello world', Inline::parse($data));
|
||||
}
|
||||
|
||||
public function getBinaryData()
|
||||
{
|
||||
return array(
|
||||
'enclosed with double quotes' => array('!!binary "SGVsbG8gd29ybGQ="'),
|
||||
'enclosed with single quotes' => array("!!binary 'SGVsbG8gd29ybGQ='"),
|
||||
'containing spaces' => array('!!binary "SGVs bG8gd 29ybGQ="'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidBinaryData
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
||||
}
|
||||
|
||||
Inline::parse($data);
|
||||
}
|
||||
|
||||
public function getInvalidBinaryData()
|
||||
{
|
||||
return array(
|
||||
'length not a multiple of four' => array('!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'),
|
||||
'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'too many equals characters' => array('!!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
|
||||
*/
|
||||
public function testNotSupportedMissingValue()
|
||||
{
|
||||
Inline::parse('{this, is not, supported}');
|
||||
}
|
||||
|
||||
public function testVeryLongQuotedStrings()
|
||||
{
|
||||
$longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
|
||||
|
||||
$yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
|
||||
$arrayFromYaml = Inline::parse($yamlString);
|
||||
|
||||
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0 on line 1.
|
||||
*/
|
||||
public function testOmittedMappingKeyIsParsedAsColon()
|
||||
{
|
||||
$this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForNullValues
|
||||
*/
|
||||
public function testParseMissingMappingValueAsNull($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml));
|
||||
}
|
||||
|
||||
public function getTestsForNullValues()
|
||||
{
|
||||
return array(
|
||||
'null before closing curly brace' => array('{foo:}', array('foo' => null)),
|
||||
'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testTheEmptyStringIsAValidMappingKey()
|
||||
{
|
||||
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
|
||||
* @dataProvider getNotPhpCompatibleMappingKeyData
|
||||
*/
|
||||
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.
|
||||
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
|
||||
* @dataProvider getNotPhpCompatibleMappingKeyData
|
||||
*/
|
||||
public function testExplicitStringCastingOfMappingKeys($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
}
|
||||
|
||||
public function getNotPhpCompatibleMappingKeyData()
|
||||
{
|
||||
return array(
|
||||
'boolean-true' => array('{true: "foo"}', array('true' => 'foo')),
|
||||
'boolean-false' => array('{false: "foo"}', array('false' => 'foo')),
|
||||
'null' => array('{null: "foo"}', array('null' => 'foo')),
|
||||
'float' => array('{0.25: "foo"}', array('0.25' => 'foo')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead on line 1.
|
||||
*/
|
||||
public function testDeprecatedStrTag()
|
||||
{
|
||||
$this->assertSame(array('foo' => 'bar'), Inline::parse('{ foo: !str bar }'));
|
||||
}
|
||||
}
|
34
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
Normal file
34
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
class ParseExceptionTest extends TestCase
|
||||
{
|
||||
public function testGetMessage()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
|
||||
public function testGetMessageWithUnicodeInFilename()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
}
|
2176
vendor/symfony/yaml/Tests/ParserTest.php
vendored
Normal file
2176
vendor/symfony/yaml/Tests/ParserTest.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
44
vendor/symfony/yaml/Tests/YamlTest.php
vendored
Normal file
44
vendor/symfony/yaml/Tests/YamlTest.php
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlTest extends TestCase
|
||||
{
|
||||
public function testParseAndDump()
|
||||
{
|
||||
$data = array('lorem' => 'ipsum', 'dolor' => 'sit');
|
||||
$yml = Yaml::dump($data);
|
||||
$parsed = Yaml::parse($yml);
|
||||
$this->assertEquals($data, $parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testZeroIndentationThrowsException()
|
||||
{
|
||||
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testNegativeIndentationThrowsException()
|
||||
{
|
||||
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue