From 7c93761aa4295c60ff54f81b63d8a434fae14a0e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 3 Nov 2024 16:54:30 +0100 Subject: [PATCH] Fix compatibility with PHPUnit 11 --- .../AddSwiftMailerTransportPassTest.php | 5 +--- .../DependencyInjection/ConfigurationTest.php | 6 ++--- ...st.php => DependencyInjectionTestCase.php} | 2 +- ...hp => FixtureMonologExtensionTestCase.php} | 2 +- .../MonologExtensionTest.php | 26 +++++-------------- .../XmlMonologExtensionTest.php | 2 +- .../YamlMonologExtensionTest.php | 2 +- 7 files changed, 14 insertions(+), 31 deletions(-) rename Tests/DependencyInjection/{DependencyInjectionTest.php => DependencyInjectionTestCase.php} (96%) rename Tests/DependencyInjection/{FixtureMonologExtensionTest.php => FixtureMonologExtensionTestCase.php} (99%) diff --git a/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php b/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php index 5e24c70a..5cff5d7f 100644 --- a/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php @@ -28,10 +28,7 @@ class AddSwiftMailerTransportPassTest extends TestCase private $definition; - /** - * @before - */ - protected function doSetUp() + protected function setUp(): void { $this->compilerPass = new AddSwiftMailerTransportPass(); $this->definition = new Definition(null, [new Reference('swiftmailer')]); diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 4ce0bfa3..d581a049 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -42,7 +42,7 @@ public function testProcessSimpleCase() $this->assertFalse($config['handlers']['foobar']['nested']); } - public function provideProcessStringChannels() + public static function provideProcessStringChannels(): array { return [ ['foo', 'foo', true], @@ -74,7 +74,7 @@ public function testProcessStringChannels($string, $expectedString, $isInclusive $this->assertEquals($expectedString, $config['handlers']['foobar']['channels']['elements'][0]); } - public function provideGelfPublisher() + public static function provideGelfPublisher(): array { return [ [ @@ -532,7 +532,7 @@ public function testWithProcessPsr3Messages(array $configuration, array $process $this->assertEquals($processedConfiguration, $config['handlers']['main']['process_psr_3_messages']); } - public function processPsr3MessagesProvider(): iterable + public static function processPsr3MessagesProvider(): iterable { yield 'Not specified' => [[], ['enabled' => null]]; diff --git a/Tests/DependencyInjection/DependencyInjectionTest.php b/Tests/DependencyInjection/DependencyInjectionTestCase.php similarity index 96% rename from Tests/DependencyInjection/DependencyInjectionTest.php rename to Tests/DependencyInjection/DependencyInjectionTestCase.php index 54a4c3f8..b6493e8a 100644 --- a/Tests/DependencyInjection/DependencyInjectionTest.php +++ b/Tests/DependencyInjection/DependencyInjectionTestCase.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; -abstract class DependencyInjectionTest extends TestCase +abstract class DependencyInjectionTestCase extends TestCase { /** * Assertion on the Class of a DIC Service Definition. diff --git a/Tests/DependencyInjection/FixtureMonologExtensionTest.php b/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php similarity index 99% rename from Tests/DependencyInjection/FixtureMonologExtensionTest.php rename to Tests/DependencyInjection/FixtureMonologExtensionTestCase.php index dd0046f5..fb6dbf96 100644 --- a/Tests/DependencyInjection/FixtureMonologExtensionTest.php +++ b/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php @@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -abstract class FixtureMonologExtensionTest extends DependencyInjectionTest +abstract class FixtureMonologExtensionTestCase extends DependencyInjectionTestCase { public function testLoadWithSeveralHandlers() { diff --git a/Tests/DependencyInjection/MonologExtensionTest.php b/Tests/DependencyInjection/MonologExtensionTest.php index a0c82005..eb02825f 100644 --- a/Tests/DependencyInjection/MonologExtensionTest.php +++ b/Tests/DependencyInjection/MonologExtensionTest.php @@ -30,7 +30,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\RequestStack; -class MonologExtensionTest extends DependencyInjectionTest +class MonologExtensionTest extends DependencyInjectionTestCase { public function testLoadWithDefault() { @@ -628,7 +628,7 @@ public function testV2Removed(array $handlerOptions) $loader->load([['handlers' => ['main' => $handlerOptions]]], $container); } - public function v2RemovedDataProvider(): array + public static function v2RemovedDataProvider(): array { return [ [['type' => 'hipchat', 'token' => 'abc123', 'room' => 'foo']], @@ -637,33 +637,19 @@ public function v2RemovedDataProvider(): array ]; } - /** - * @dataProvider v1AddedDataProvider - */ - public function testV2AddedOnV1(string $handlerType) + public function testV2AddedOnV1() { if (Logger::API !== 1) { $this->markTestSkipped('Only valid on Monolog V1'); - - return; } $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage( - \sprintf('"%s" was added in Monolog v2, please upgrade if you wish to use it.', $handlerType) - ); + $this->expectExceptionMessage('"fallbackgroup" was added in Monolog v2, please upgrade if you wish to use it.'); $container = new ContainerBuilder(); $loader = new MonologExtension(); - $loader->load([['handlers' => ['main' => ['type' => $handlerType]]]], $container); - } - - public function v1AddedDataProvider(): array - { - return [ - ['fallbackgroup'], - ]; + $loader->load([['handlers' => ['main' => ['type' => 'fallbackgroup']]]], $container); } /** @@ -684,7 +670,7 @@ public function testLogLevelfromParameter(array $parameters, array $config, $exp $this->assertDICConstructorArguments($definition, $expectedArgs); } - public function provideLoglevelParameterConfig(): array + public static function provideLoglevelParameterConfig(): array { return [ 'browser console with parameter level' => [ diff --git a/Tests/DependencyInjection/XmlMonologExtensionTest.php b/Tests/DependencyInjection/XmlMonologExtensionTest.php index e82f982e..7c6656bf 100644 --- a/Tests/DependencyInjection/XmlMonologExtensionTest.php +++ b/Tests/DependencyInjection/XmlMonologExtensionTest.php @@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -class XmlMonologExtensionTest extends FixtureMonologExtensionTest +class XmlMonologExtensionTest extends FixtureMonologExtensionTestCase { protected function loadFixture(ContainerBuilder $container, $fixture) { diff --git a/Tests/DependencyInjection/YamlMonologExtensionTest.php b/Tests/DependencyInjection/YamlMonologExtensionTest.php index 332aef6a..dcd16d0c 100644 --- a/Tests/DependencyInjection/YamlMonologExtensionTest.php +++ b/Tests/DependencyInjection/YamlMonologExtensionTest.php @@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -class YamlMonologExtensionTest extends FixtureMonologExtensionTest +class YamlMonologExtensionTest extends FixtureMonologExtensionTestCase { protected function loadFixture(ContainerBuilder $container, $fixture) {