Skip to content

Commit

Permalink
Merge branch '4.4' into 5.1
Browse files Browse the repository at this point in the history
* 4.4:
  Use ::class keyword when possible
  • Loading branch information
fabpot committed Jan 11, 2021
2 parents db17469 + 22640fb commit e49580b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testCustomTagsError()

public function testLintFileNotReadable()
{
$this->expectException('RuntimeException');
$this->expectException(\RuntimeException::class);
$tester = $this->createCommandTester();
$filename = $this->createFile('');
unlink($filename);
Expand Down
6 changes: 3 additions & 3 deletions Tests/DumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function testObjectSupportDisabledButNoExceptions()

public function testObjectSupportDisabledWithExceptions()
{
$this->expectException('Symfony\Component\Yaml\Exception\DumpException');
$this->expectException(\Symfony\Component\Yaml\Exception\DumpException::class);
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
}

Expand Down Expand Up @@ -619,14 +619,14 @@ public function testDumpTrailingNewlineInMultiLineLiteralBlocks()

public function testZeroIndentationThrowsException()
{
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The indentation must be greater than zero');
new Dumper(0);
}

public function testNegativeIndentationThrowsException()
{
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The indentation must be greater than zero');
new Dumper(-4);
}
Expand Down
36 changes: 18 additions & 18 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public function getTestsForParsePhpConstants()

public function testParsePhpConstantThrowsExceptionWhenUndefined()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined');
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
}

public function testParsePhpConstantThrowsExceptionOnInvalidType()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessageMatches('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#');
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
}
Expand Down Expand Up @@ -120,60 +120,60 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo

public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Found unknown escape character "\V".');
Inline::parse('"Foo\Var"');
}

public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
Inline::parse('"Foo\\"');
}

public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$value = "'don't do somthin' like that'";
Inline::parse($value);
}

public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$value = '"don"t do somthin" like that"';
Inline::parse($value);
}

public function testParseInvalidMappingKeyShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$value = '{ "foo " bar": "bar" }';
Inline::parse($value);
}

public function testParseMappingKeyWithColonNotFollowedBySpace()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")');
Inline::parse('{foo:""}');
}

public function testParseInvalidMappingShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
Inline::parse('[foo] bar');
}

public function testParseInvalidSequenceShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
Inline::parse('{ foo: bar } bar');
}

public function testParseInvalidTaggedSequenceShouldThrowException()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS);
}

Expand Down Expand Up @@ -219,14 +219,14 @@ public function testParseMapReferenceInSequence()

public function testParseUnquotedAsterisk()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
Inline::parse('{ foo: * }');
}

public function testParseUnquotedAsteriskFollowedByAComment()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
Inline::parse('{ foo: * #foo }');
}
Expand Down Expand Up @@ -613,7 +613,7 @@ public function getBinaryData()
*/
public function testParseInvalidBinaryData($data, $expectedMessage)
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessageMatches($expectedMessage);

Inline::parse($data);
Expand All @@ -631,7 +631,7 @@ public function getInvalidBinaryData()

public function testNotSupportedMissingValue()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Malformed inline YAML string: "{this, is not, supported}" at line 1.');
Inline::parse('{this, is not, supported}');
}
Expand All @@ -648,7 +648,7 @@ public function testVeryLongQuotedStrings()

public function testMappingKeysCannotBeOmitted()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Missing mapping key');
Inline::parse('{: foo}');
}
Expand Down Expand Up @@ -679,7 +679,7 @@ public function testTheEmptyStringIsAValidMappingKey()
*/
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead');
$this->assertSame($expected, Inline::parse($yaml));
}
Expand Down Expand Up @@ -732,7 +732,7 @@ public function testTagWithEmptyValueInMapping()

public function testUnfinishedInlineMap()
{
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectException(ParseException::class);
$this->expectExceptionMessage("Unexpected end of line, expected one of \",}\n\" at line 1 (near \"{abc: 'def'\").");
Inline::parse("{abc: 'def'");
}
Expand Down
Loading

0 comments on commit e49580b

Please sign in to comment.