Skip to content

Commit 066563a

Browse files
Merge branch '3.4' into 4.3
* 3.4: cs fix Replace calls to setExpectedException by Pollyfill
2 parents 6315e5f + 17eea3c commit 066563a

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

Tests/Compiler/AutowirePassTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPUnit\Framework\Warning;
1616
use Psr\Log\LoggerInterface;
1717
use Psr\Log\NullLogger;
18+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1819
use Symfony\Component\Config\FileLocator;
1920
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
2021
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
@@ -36,6 +37,8 @@
3637
*/
3738
class AutowirePassTest extends TestCase
3839
{
40+
use ForwardCompatTestTrait;
41+
3942
public function testProcess()
4043
{
4144
$container = new ContainerBuilder();
@@ -750,12 +753,8 @@ public function testNotWireableCalls($method, $expectedMsg)
750753
$foo->addMethodCall($method, []);
751754
}
752755

753-
if (method_exists($this, 'expectException')) {
754-
$this->expectException(RuntimeException::class);
755-
$this->expectExceptionMessage($expectedMsg);
756-
} else {
757-
$this->setExpectedException(RuntimeException::class, $expectedMsg);
758-
}
756+
$this->expectException(RuntimeException::class);
757+
$this->expectExceptionMessage($expectedMsg);
759758

760759
(new ResolveClassPass())->process($container);
761760
(new AutowireRequiredMethodsPass())->process($container);

Tests/DefinitionTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace Symfony\Component\DependencyInjection\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Definition;
1617
use Symfony\Component\DependencyInjection\Reference;
1718

1819
class DefinitionTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
public function testConstructor()
2124
{
2225
$def = new Definition('stdClass');
@@ -73,12 +76,8 @@ public function testSetGetDecoratedService()
7376

7477
$def = new Definition('stdClass');
7578

76-
if (method_exists($this, 'expectException')) {
77-
$this->expectException('InvalidArgumentException');
78-
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
79-
} else {
80-
$this->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.');
81-
}
79+
$this->expectException('InvalidArgumentException');
80+
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
8281

8382
$def->setDecoratedService('foo', 'foo');
8483
}

Tests/Dumper/PhpDumperTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,8 @@ public function testCircularReferenceAllowanceForLazyServices()
704704
$dumper = new PhpDumper($container);
705705

706706
$message = 'Circular reference detected for service "foo", path: "foo -> bar -> foo". Try running "composer require symfony/proxy-manager-bridge".';
707-
if (method_exists($this, 'expectException')) {
708-
$this->expectException(ServiceCircularReferenceException::class);
709-
$this->expectExceptionMessage($message);
710-
} else {
711-
$this->setExpectedException(ServiceCircularReferenceException::class, $message);
712-
}
707+
$this->expectException(ServiceCircularReferenceException::class);
708+
$this->expectExceptionMessage($message);
713709

714710
$dumper->dump();
715711
}

Tests/ParameterBag/ParameterBagTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
1617
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1718
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1819
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1920

2021
class ParameterBagTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
public function testConstructor()
2326
{
2427
$bag = new ParameterBag($parameters = [
@@ -78,12 +81,8 @@ public function testGetThrowParameterNotFoundException($parameterKey, $exception
7881
'fiz' => ['bar' => ['boo' => 12]],
7982
]);
8083

81-
if (method_exists($this, 'expectException')) {
82-
$this->expectException(ParameterNotFoundException::class);
83-
$this->expectExceptionMessage($exceptionMessage);
84-
} else {
85-
$this->setExpectedException(ParameterNotFoundException::class, $exceptionMessage);
86-
}
84+
$this->expectException(ParameterNotFoundException::class);
85+
$this->expectExceptionMessage($exceptionMessage);
8786

8887
$bag->get($parameterKey);
8988
}

0 commit comments

Comments
 (0)