update v 1.0.7.5
This commit is contained in:
137
vendor/symfony/yaml/Tests/DumperTest.php
vendored
137
vendor/symfony/yaml/Tests/DumperTest.php
vendored
@@ -13,6 +13,7 @@ namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class DumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -50,6 +51,34 @@ class DumperTest extends \PHPUnit_Framework_TestCase
|
||||
$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);
|
||||
@@ -177,6 +206,16 @@ EOF;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -195,7 +234,16 @@ EOF;
|
||||
*/
|
||||
public function testObjectSupportDisabledWithExceptions()
|
||||
{
|
||||
$this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,6 +276,93 @@ EOF;
|
||||
'paragraph-separator' => array("\t\\P", '"\t\\\\P"'),
|
||||
);
|
||||
}
|
||||
|
||||
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 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, 3, 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
|
||||
|
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 |
14
vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Normal file
14
vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
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"
|
148
vendor/symfony/yaml/Tests/InlineTest.php
vendored
148
vendor/symfony/yaml/Tests/InlineTest.php
vendored
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -27,6 +28,17 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider getTestsForParseWithMapObjects
|
||||
*/
|
||||
public function testParseWithMapObjects($yaml, $value)
|
||||
{
|
||||
$actual = Inline::parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP);
|
||||
|
||||
$this->assertSame(serialize($value), serialize($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getTestsForParseWithMapObjects
|
||||
*/
|
||||
public function testParseWithMapObjectsPassingTrue($yaml, $value)
|
||||
{
|
||||
$actual = Inline::parse($yaml, false, false, true);
|
||||
|
||||
@@ -142,6 +154,15 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
* @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')));
|
||||
}
|
||||
@@ -161,6 +182,19 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
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',
|
||||
@@ -218,6 +252,31 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
return array(array('|'), array('>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithPercentCharacter()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
Inline::parse('{ foo: %foo }');
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $deprecations[0]);
|
||||
}
|
||||
|
||||
public function getTestsForParse()
|
||||
{
|
||||
return array(
|
||||
@@ -426,4 +485,93 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
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')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
$expected->setTime($hour, $minute, $second);
|
||||
|
||||
$this->assertEquals($expected, Inline::parse($yaml, Yaml::PARSE_DATETIME));
|
||||
}
|
||||
|
||||
public function getTimestampTests()
|
||||
{
|
||||
return array(
|
||||
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43),
|
||||
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43),
|
||||
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43),
|
||||
'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
$this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $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/'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
170
vendor/symfony/yaml/Tests/ParserTest.php
vendored
170
vendor/symfony/yaml/Tests/ParserTest.php
vendored
@@ -422,11 +422,17 @@ EOF;
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$input = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testObjectSupportEnabledPassingTrue()
|
||||
{
|
||||
$input = <<<EOF
|
||||
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
@@ -434,6 +440,18 @@ EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testObjectSupportEnabledWithDeprecatedTag()
|
||||
{
|
||||
$input = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidDumpedObjectProvider
|
||||
*/
|
||||
@@ -446,6 +464,15 @@ EOF;
|
||||
* @dataProvider getObjectForMapTests
|
||||
*/
|
||||
public function testObjectForMap($yaml, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getObjectForMapTests
|
||||
*/
|
||||
public function testObjectForMapEnabledWithMappingUsingBooleanToggles($yaml, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, false, false, true));
|
||||
}
|
||||
@@ -519,7 +546,17 @@ YAML;
|
||||
*/
|
||||
public function testObjectsSupportDisabledWithExceptions($yaml)
|
||||
{
|
||||
$this->parser->parse($yaml, true, false);
|
||||
$this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider invalidDumpedObjectProvider
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testObjectsSupportDisabledWithExceptionsUsingBooleanToggles($yaml)
|
||||
{
|
||||
$this->parser->parse($yaml, true);
|
||||
}
|
||||
|
||||
public function invalidDumpedObjectProvider()
|
||||
@@ -596,7 +633,7 @@ EOF;
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Multiple documents are not supported.
|
||||
* @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/
|
||||
*/
|
||||
public function testMultipleDocumentsNotSupportedException()
|
||||
{
|
||||
@@ -628,6 +665,34 @@ EOF
|
||||
);
|
||||
}
|
||||
|
||||
public function testSequenceInMappingStartedBySingleDashLine()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
a:
|
||||
-
|
||||
b:
|
||||
-
|
||||
bar: baz
|
||||
- foo
|
||||
d: e
|
||||
EOT;
|
||||
$expected = array(
|
||||
'a' => array(
|
||||
array(
|
||||
'b' => array(
|
||||
array(
|
||||
'bar' => 'baz',
|
||||
),
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
),
|
||||
'd' => 'e',
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
@@ -977,6 +1042,7 @@ EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
|
||||
EOT
|
||||
,
|
||||
),
|
||||
@@ -1005,7 +1071,7 @@ EOT;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'bar' => array(
|
||||
'scalar-block' => 'line1 line2>',
|
||||
'scalar-block' => "line1 line2>\n",
|
||||
),
|
||||
'baz' => array(
|
||||
'foobar' => null,
|
||||
@@ -1083,6 +1149,100 @@ EOT
|
||||
$this->parser->parse($yaml)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getBinaryData
|
||||
*/
|
||||
public function testParseBinaryData($data)
|
||||
{
|
||||
$this->assertSame(array('data' => 'Hello world'), $this->parser->parse($data));
|
||||
}
|
||||
|
||||
public function getBinaryData()
|
||||
{
|
||||
return array(
|
||||
'enclosed with double quotes' => array('data: !!binary "SGVsbG8gd29ybGQ="'),
|
||||
'enclosed with single quotes' => array("data: !!binary 'SGVsbG8gd29ybGQ='"),
|
||||
'containing spaces' => array('data: !!binary "SGVs bG8gd 29ybGQ="'),
|
||||
'in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVsbG8gd29ybGQ=
|
||||
EOT
|
||||
),
|
||||
'containing spaces in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVs bG8gd 29ybGQ=
|
||||
EOT
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidBinaryData
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
$this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $expectedMessage);
|
||||
|
||||
$this->parser->parse($data);
|
||||
}
|
||||
|
||||
public function getInvalidBinaryData()
|
||||
{
|
||||
return array(
|
||||
'length not a multiple of four' => array('data: !!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('data: !!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'misplaced equals character' => array('data: !!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'length not a multiple of four in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVsbG8d29ybGQ=
|
||||
EOT
|
||||
,
|
||||
'/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/',
|
||||
),
|
||||
'invalid characters in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVsbG8#d29ybGQ=
|
||||
EOT
|
||||
,
|
||||
'/The base64 encoded data \(.*\) contains invalid characters/',
|
||||
),
|
||||
'too many equals characters in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVsbG8gd29yb===
|
||||
EOT
|
||||
,
|
||||
'/The base64 encoded data \(.*\) contains invalid characters/',
|
||||
),
|
||||
'misplaced equals character in block scalar' => array(
|
||||
<<<EOT
|
||||
data: !!binary |
|
||||
SGVsbG8gd29ybG=Q
|
||||
EOT
|
||||
,
|
||||
'/The base64 encoded data \(.*\) contains invalid characters/',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testParseDateAsMappingValue()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
date: 2002-12-14
|
||||
EOT;
|
||||
$expectedDate = new \DateTime();
|
||||
$expectedDate->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expectedDate->setDate(2002, 12, 14);
|
||||
$expectedDate->setTime(0, 0, 0);
|
||||
|
||||
$this->assertEquals(array('date' => $expectedDate), $this->parser->parse($yaml, Yaml::PARSE_DATETIME));
|
||||
}
|
||||
}
|
||||
|
||||
class B
|
||||
|
18
vendor/symfony/yaml/Tests/YamlTest.php
vendored
18
vendor/symfony/yaml/Tests/YamlTest.php
vendored
@@ -22,4 +22,22 @@ class YamlTest extends \PHPUnit_Framework_TestCase
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user