Skip to content

Commit b01eaca

Browse files
committed
Replace calls to setExpectedException by Pollyfill
1 parent c204535 commit b01eaca

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Tests/Generator/UrlGeneratorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Routing\Tests\Generator;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Routing\Generator\UrlGenerator;
1617
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1718
use Symfony\Component\Routing\RequestContext;
@@ -20,6 +21,8 @@
2021

2122
class UrlGeneratorTest extends TestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
public function testAbsoluteUrlWithPort80()
2427
{
2528
$routes = $this->getRoutes('test', new Route('/testing'));
@@ -368,7 +371,7 @@ public function testAdjacentVariables()
368371

369372
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
370373
// and following optional variables like _format could never match.
371-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
374+
$this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
372375
$generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);
373376
}
374377

Tests/Matcher/UrlMatcherTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testMatchOverriddenRoute()
225225
$matcher = $this->getUrlMatcher($collection);
226226

227227
$this->assertEquals(['_route' => 'foo'], $matcher->match('/foo1'));
228-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
228+
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
229229
$this->assertEquals([], $matcher->match('/foo'));
230230
}
231231

@@ -282,7 +282,7 @@ public function testAdjacentVariables()
282282
// z and _format are optional.
283283
$this->assertEquals(['w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'], $matcher->match('/wwwwwxy'));
284284

285-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
285+
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
286286
$matcher->match('/wxy.html');
287287
}
288288

@@ -297,7 +297,7 @@ public function testOptionalVariableWithNoRealSeparator()
297297

298298
// Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match.
299299
// But here the 't' in 'get' is not a separating character, so it makes no sense to match without it.
300-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
300+
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
301301
$matcher->match('/ge');
302302
}
303303

0 commit comments

Comments
 (0)