[Yaml] Clean some messages + add test case

This commit is contained in:
Nicolas Grekas 2016-11-02 14:42:53 +01:00
parent 620ea20f49
commit 7520f7b937
2 changed files with 13 additions and 4 deletions

View File

@ -249,7 +249,7 @@ class Inline
$output = $match[1];
$i += strlen($output);
} else {
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar));
}
if ($evaluate) {
@ -273,7 +273,7 @@ class Inline
private static function parseQuotedScalar($scalar, &$i)
{
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
}
$output = substr($match[0], 1, strlen($match[0]) - 2);
@ -346,7 +346,7 @@ class Inline
++$i;
}
throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence));
}
/**
@ -434,7 +434,7 @@ class Inline
}
}
throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping));
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
}
/**

View File

@ -401,4 +401,13 @@ class InlineTest extends \PHPUnit_Framework_TestCase
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
);
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
*/
public function testNotSupportedMissingValue()
{
Inline::parse('{this, is not, supported}');
}
}