Skip to content

Commit 749d918

Browse files
minor #21688 Further refactorings to PHPUnit namespaces (peterrehm)
This PR was squashed before being merged into the 2.7 branch (closes #21688). Discussion ---------- Further refactorings to PHPUnit namespaces | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - Continued work to make Symfony PHPUnit 6 compatible Commits ------- de8106f Further refactorings to PHPUnit namespaces
2 parents 69614da + 918b2de commit 749d918

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

Tests/Controller/ControllerResolverTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ public function testGetControllerInvokableServiceWithClassNameAsName()
141141
*/
142142
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
143143
{
144-
$this->setExpectedException($exceptionName, $exceptionMessage);
144+
if (method_exists($this, 'expectException')) {
145+
$this->expectException($exceptionName);
146+
$this->expectExceptionMessage($exceptionMessage);
147+
} else {
148+
$this->setExpectedException($exceptionName, $exceptionMessage);
149+
}
145150

146151
parent::testGetControllerOnNonUndefinedFunction($controller);
147152
}

Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\Translation\TranslatorInterface;
1819

19-
class DataCollectorTranslatorPassTest extends \PHPUnit_Framework_TestCase
20+
class DataCollectorTranslatorPassTest extends TestCase
2021
{
2122
private $container;
2223
private $dataCollectorTranslatorPass;

Tests/DependencyInjection/Compiler/ProfilerPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testTemplateNoIdThrowsException()
4141

4242
$builder = $this->createContainerMock($services);
4343

44-
$this->setExpectedException('InvalidArgumentException');
44+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
4545

4646
$profilerPass = new ProfilerPass();
4747
$profilerPass->process($builder);

Tests/DependencyInjection/Compiler/SerializerPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testThrowExceptionWhenNoNormalizers()
3636
->with('serializer.normalizer')
3737
->will($this->returnValue(array()));
3838

39-
$this->setExpectedException('RuntimeException');
39+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
4040

4141
$serializerPass = new SerializerPass();
4242
$serializerPass->process($container);
@@ -63,7 +63,7 @@ public function testThrowExceptionWhenNoEncoders()
6363
->method('getDefinition')
6464
->will($this->returnValue($definition));
6565

66-
$this->setExpectedException('RuntimeException');
66+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
6767

6868
$serializerPass = new SerializerPass();
6969
$serializerPass->process($container);

Tests/Translation/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testTransWithCachingWithInvalidLocale()
101101
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
102102
$translator->setLocale('invalid locale');
103103

104-
$this->setExpectedException('\InvalidArgumentException');
104+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
105105
$translator->trans('foo');
106106
}
107107

0 commit comments

Comments
 (0)