From af88e9dce717662e07659b678feb6469f866c986 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 | 13 +++++----- .../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, 19 insertions(+), 34 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 bb743fbe..b01b7b27 100644 --- a/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddSwiftMailerTransportPassTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddSwiftMailerTransportPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** @@ -26,19 +28,16 @@ class AddSwiftMailerTransportPassTest extends TestCase private $definition; - /** - * @before - */ - protected function doSetUp() + protected function setUp(): void { $this->compilerPass = new AddSwiftMailerTransportPass(); - $this->definition = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Definition')->getMock(); + $this->definition = $this->getMockBuilder(Definition::class)->getMock(); $this->definition->expects($this->any()) ->method('getArgument') ->with(0) ->willReturn(new Reference('swiftmailer')); - $this->container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder') - ->setMethods(['getParameter', 'getDefinition', 'hasDefinition', 'addMethodCall'])->getMock(); + $this->container = $this->getMockBuilder(ContainerBuilder::class) + ->onlyMethods(['getParameter', 'getDefinition', 'hasDefinition'])->getMock(); $this->container->expects($this->any()) ->method('getParameter') ->with('monolog.swift_mailer.handlers') diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 516565e0..1c30d103 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -41,7 +41,7 @@ public function testProcessSimpleCase() $this->assertFalse($config['handlers']['foobar']['nested']); } - public function provideProcessStringChannels() + public static function provideProcessStringChannels(): array { return [ ['foo', 'foo', true], @@ -73,7 +73,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 [ [ @@ -531,7 +531,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]]; yield 'Null' => [['process_psr_3_messages' => null], ['enabled' => true]]; 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) {