From 5a488552dd1fa12b47d63cff9e3fc68296831c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Poirier=20Th=C3=A9or=C3=AAt?= Date: Fri, 28 Jun 2024 16:53:11 -0400 Subject: [PATCH] [All] fix split test --- .../ConfigurationIntegrationTest.php | 3 +- .../SystemMonitoringIntegrationTest.php | 3 +- packages/application/composer.json | 3 +- .../ConsoleIntegrationTest.php | 2 +- .../Integration/IntegrationTrait.php | 1 + .../Integration/Test/IntegrationTestCase.php | 17 +++++++++++ .../DependencyInjectionIntegrationTest.php | 30 +++++++++++++++++++ packages/dependency-injection/composer.json | 3 +- 8 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php diff --git a/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php b/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php index e3326bcf..da9f72de 100644 --- a/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php @@ -2,7 +2,6 @@ namespace Draw\Component\Application\Tests\DependencyInjection; -use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; use Draw\Component\Application\Configuration\DoctrineConfigurationRegistry; use Draw\Component\Application\Configuration\Entity\Config; use Draw\Component\Application\DependencyInjection\ConfigurationIntegration; @@ -49,7 +48,7 @@ public function testPrependNoDoctrineExtension(): void public function testPrepend(): void { $containerBuilder = new ContainerBuilder(); - $containerBuilder->registerExtension(new DoctrineExtension()); + $containerBuilder->registerExtension($this->mockExtension('doctrine')); $this->integration->prepend( $containerBuilder, diff --git a/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php b/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php index f22b0e15..ba65da3b 100644 --- a/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php @@ -2,7 +2,6 @@ namespace Draw\Component\Application\Tests\DependencyInjection; -use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\DrawFrameworkExtraExtension; use Draw\Component\Application\DependencyInjection\SystemMonitoringIntegration; use Draw\Component\Application\SystemMonitoring\Action\PingAction; use Draw\Component\Application\SystemMonitoring\Bridge\Doctrine\DBALConnectionStatusProvider; @@ -45,7 +44,7 @@ public function getDefaultConfiguration(): array public function testPrepend(): void { $containerBuilder = new ContainerBuilder(); - $containerBuilder->registerExtension(new DrawFrameworkExtraExtension()); + $containerBuilder->registerExtension($this->mockExtension('draw_framework_extra')); $this->integration->prepend( $containerBuilder, diff --git a/packages/application/composer.json b/packages/application/composer.json index 0af6865e..a5a237a3 100644 --- a/packages/application/composer.json +++ b/packages/application/composer.json @@ -20,7 +20,8 @@ "draw/dependency-injection": "^0.11", "draw/tester": "^0.11", "symfony/cache": "^6.4.0", - "symfony/console": "^6.4.0" + "symfony/console": "^6.4.0", + "symfony/messenger": "^6.4.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php b/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php index 66b376b6..3db0e33d 100644 --- a/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php +++ b/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php @@ -60,7 +60,7 @@ public function testPrependNoDoctrineExtension(): void public function testPrepend(): void { $containerBuilder = new ContainerBuilder(); - $containerBuilder->registerExtension(new DoctrineExtension()); + $containerBuilder->registerExtension($this->mockExtension('doctrine')); $this->integration->prepend( $containerBuilder, diff --git a/packages/dependency-injection/Integration/IntegrationTrait.php b/packages/dependency-injection/Integration/IntegrationTrait.php index 295c6c2d..7c46fb55 100644 --- a/packages/dependency-injection/Integration/IntegrationTrait.php +++ b/packages/dependency-injection/Integration/IntegrationTrait.php @@ -24,6 +24,7 @@ private static function getDefaultExcludedDirectories(): array 'Resources/', 'Stamp/', 'Tests/', + 'vendor/', ]; } diff --git a/packages/dependency-injection/Integration/Test/IntegrationTestCase.php b/packages/dependency-injection/Integration/Test/IntegrationTestCase.php index 287ffebf..1bd1080b 100644 --- a/packages/dependency-injection/Integration/Test/IntegrationTestCase.php +++ b/packages/dependency-injection/Integration/Test/IntegrationTestCase.php @@ -10,6 +10,7 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; abstract class IntegrationTestCase extends TestCase @@ -24,6 +25,22 @@ abstract public function getDefaultConfiguration(): array; abstract public static function provideTestLoad(): iterable; + protected function mockExtension(string $name): ExtensionInterface + { + $extension = $this->createMock(ExtensionInterface::class); + + $extension->expects(static::any()) + ->method('getAlias') + ->willReturn($name); + + $extension + ->expects(static::any()) + ->method('getNamespace') + ->willReturn($name); + + return $extension; + } + protected function setUp(): void { $this->integration = $this->createIntegration(); diff --git a/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php b/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php new file mode 100644 index 00000000..7da58a11 --- /dev/null +++ b/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php @@ -0,0 +1,30 @@ +=8.1", - "symfony/config": "^6.4.0" + "symfony/config": "^6.4.0", + "symfony/dependency-injection": "^6.4.0" }, "require-dev": { "phpunit/phpunit": "^10.0"