Skip to content

Commit 8f4ad7e

Browse files
Merge branch '3.4' into 4.3
* 3.4: cs fix Replace calls to setExpectedException by Pollyfill
2 parents 94f08e1 + a77d5fe commit 8f4ad7e

File tree

2 files changed

+8
-28
lines changed

2 files changed

+8
-28
lines changed

Tests/InlineTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,8 @@ public function testParseUnquotedAsteriskFollowedByAComment()
253253
*/
254254
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
255255
{
256-
if (method_exists($this, 'expectExceptionMessage')) {
257-
$this->expectException(ParseException::class);
258-
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
259-
} else {
260-
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
261-
}
256+
$this->expectException(ParseException::class);
257+
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
262258

263259
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
264260
}
@@ -273,12 +269,8 @@ public function getReservedIndicators()
273269
*/
274270
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
275271
{
276-
if (method_exists($this, 'expectExceptionMessage')) {
277-
$this->expectException(ParseException::class);
278-
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
279-
} else {
280-
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
281-
}
272+
$this->expectException(ParseException::class);
273+
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
282274

283275
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
284276
}
@@ -627,11 +619,7 @@ public function getBinaryData()
627619
*/
628620
public function testParseInvalidBinaryData($data, $expectedMessage)
629621
{
630-
if (method_exists($this, 'expectException')) {
631-
$this->expectExceptionMessageRegExp($expectedMessage);
632-
} else {
633-
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
634-
}
622+
$this->expectExceptionMessageRegExp($expectedMessage);
635623

636624
Inline::parse($data);
637625
}

Tests/ParserTest.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,11 +1374,7 @@ public function getBinaryData()
13741374
*/
13751375
public function testParseInvalidBinaryData($data, $expectedMessage)
13761376
{
1377-
if (method_exists($this, 'expectException')) {
1378-
$this->expectExceptionMessageRegExp($expectedMessage);
1379-
} else {
1380-
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
1381-
}
1377+
$this->expectExceptionMessageRegExp($expectedMessage);
13821378

13831379
$this->parser->parse($data);
13841380
}
@@ -1445,12 +1441,8 @@ public function testParseDateAsMappingValue()
14451441
*/
14461442
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
14471443
{
1448-
if (method_exists($this, 'expectException')) {
1449-
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
1450-
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
1451-
} else {
1452-
$this->setExpectedException('\Symfony\Component\Yaml\Exception\ParseException', sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
1453-
}
1444+
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
1445+
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
14541446

14551447
$this->parser->parse($yaml);
14561448
}

0 commit comments

Comments
 (0)