Skip to content

Commit 33bf5ca

Browse files
committed
minor #493 Fix compatibility with PHPUnit 11 (derrabus)
This PR was merged into the 3.x-dev branch. Discussion ---------- Fix compatibility with PHPUnit 11 This PR fixes a couple of compatibility issues with PHPUnit 11: * Data provider methods must be static. * The mock builder does not have a `setMethods()` method anymore. * Abstract test classes must not use the suffix `Test`. Note: The tests are still run with PHPUnit 8.5 and 9.6 though. The PR merely enables us to use PHPUnit 11 in the future. Commits ------- 7c93761 Fix compatibility with PHPUnit 11
2 parents b394dfe + 7c93761 commit 33bf5ca

7 files changed

+14
-31
lines changed

Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ class AddSwiftMailerTransportPassTest extends TestCase
2828

2929
private $definition;
3030

31-
/**
32-
* @before
33-
*/
34-
protected function doSetUp()
31+
protected function setUp(): void
3532
{
3633
$this->compilerPass = new AddSwiftMailerTransportPass();
3734
$this->definition = new Definition(null, [new Reference('swiftmailer')]);

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testProcessSimpleCase()
4242
$this->assertFalse($config['handlers']['foobar']['nested']);
4343
}
4444

45-
public function provideProcessStringChannels()
45+
public static function provideProcessStringChannels(): array
4646
{
4747
return [
4848
['foo', 'foo', true],
@@ -74,7 +74,7 @@ public function testProcessStringChannels($string, $expectedString, $isInclusive
7474
$this->assertEquals($expectedString, $config['handlers']['foobar']['channels']['elements'][0]);
7575
}
7676

77-
public function provideGelfPublisher()
77+
public static function provideGelfPublisher(): array
7878
{
7979
return [
8080
[
@@ -532,7 +532,7 @@ public function testWithProcessPsr3Messages(array $configuration, array $process
532532
$this->assertEquals($processedConfiguration, $config['handlers']['main']['process_psr_3_messages']);
533533
}
534534

535-
public function processPsr3MessagesProvider(): iterable
535+
public static function processPsr3MessagesProvider(): iterable
536536
{
537537
yield 'Not specified' => [[], ['enabled' => null]];
538538

Tests/DependencyInjection/DependencyInjectionTest.php renamed to Tests/DependencyInjection/DependencyInjectionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515

16-
abstract class DependencyInjectionTest extends TestCase
16+
abstract class DependencyInjectionTestCase extends TestCase
1717
{
1818
/**
1919
* Assertion on the Class of a DIC Service Definition.

Tests/DependencyInjection/FixtureMonologExtensionTest.php renamed to Tests/DependencyInjection/FixtureMonologExtensionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Definition;
2020
use Symfony\Component\DependencyInjection\Reference;
2121

22-
abstract class FixtureMonologExtensionTest extends DependencyInjectionTest
22+
abstract class FixtureMonologExtensionTestCase extends DependencyInjectionTestCase
2323
{
2424
public function testLoadWithSeveralHandlers()
2525
{

Tests/DependencyInjection/MonologExtensionTest.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use Symfony\Component\DependencyInjection\Reference;
3131
use Symfony\Component\HttpFoundation\RequestStack;
3232

33-
class MonologExtensionTest extends DependencyInjectionTest
33+
class MonologExtensionTest extends DependencyInjectionTestCase
3434
{
3535
public function testLoadWithDefault()
3636
{
@@ -628,7 +628,7 @@ public function testV2Removed(array $handlerOptions)
628628
$loader->load([['handlers' => ['main' => $handlerOptions]]], $container);
629629
}
630630

631-
public function v2RemovedDataProvider(): array
631+
public static function v2RemovedDataProvider(): array
632632
{
633633
return [
634634
[['type' => 'hipchat', 'token' => 'abc123', 'room' => 'foo']],
@@ -637,33 +637,19 @@ public function v2RemovedDataProvider(): array
637637
];
638638
}
639639

640-
/**
641-
* @dataProvider v1AddedDataProvider
642-
*/
643-
public function testV2AddedOnV1(string $handlerType)
640+
public function testV2AddedOnV1()
644641
{
645642
if (Logger::API !== 1) {
646643
$this->markTestSkipped('Only valid on Monolog V1');
647-
648-
return;
649644
}
650645

651646
$this->expectException(\InvalidArgumentException::class);
652-
$this->expectExceptionMessage(
653-
\sprintf('"%s" was added in Monolog v2, please upgrade if you wish to use it.', $handlerType)
654-
);
647+
$this->expectExceptionMessage('"fallbackgroup" was added in Monolog v2, please upgrade if you wish to use it.');
655648

656649
$container = new ContainerBuilder();
657650
$loader = new MonologExtension();
658651

659-
$loader->load([['handlers' => ['main' => ['type' => $handlerType]]]], $container);
660-
}
661-
662-
public function v1AddedDataProvider(): array
663-
{
664-
return [
665-
['fallbackgroup'],
666-
];
652+
$loader->load([['handlers' => ['main' => ['type' => 'fallbackgroup']]]], $container);
667653
}
668654

669655
/**
@@ -684,7 +670,7 @@ public function testLogLevelfromParameter(array $parameters, array $config, $exp
684670
$this->assertDICConstructorArguments($definition, $expectedArgs);
685671
}
686672

687-
public function provideLoglevelParameterConfig(): array
673+
public static function provideLoglevelParameterConfig(): array
688674
{
689675
return [
690676
'browser console with parameter level' => [

Tests/DependencyInjection/XmlMonologExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1818

19-
class XmlMonologExtensionTest extends FixtureMonologExtensionTest
19+
class XmlMonologExtensionTest extends FixtureMonologExtensionTestCase
2020
{
2121
protected function loadFixture(ContainerBuilder $container, $fixture)
2222
{

Tests/DependencyInjection/YamlMonologExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1818

19-
class YamlMonologExtensionTest extends FixtureMonologExtensionTest
19+
class YamlMonologExtensionTest extends FixtureMonologExtensionTestCase
2020
{
2121
protected function loadFixture(ContainerBuilder $container, $fixture)
2222
{

0 commit comments

Comments
 (0)