From ca20d882155f731fcc0aec6e3c3c3b118cfc5ee1 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 | 3 +- .../Integration/IntegrationTrait.php | 1 + .../Integration/Test/IntegrationTestCase.php | 17 +++++++++++ .../DependencyInjectionIntegrationTest.php | 30 +++++++++++++++++++ packages/dependency-injection/composer.json | 3 +- packages/log/composer.json | 4 ++- .../MailerIntegrationTest.php | 6 ++-- .../MessengerIntegration.php | 1 + .../MessengerIntegrationTest.php | 9 ++---- packages/open-api/composer.json | 1 + packages/validator/composer.json | 3 +- 14 files changed, 67 insertions(+), 20 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..16bcf5c5 100644 --- a/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php +++ b/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php @@ -2,7 +2,6 @@ namespace Draw\Component\Console\Tests\DependencyInjection; -use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; use Draw\Component\Console\Command\GenerateDocumentationCommand; use Draw\Component\Console\Command\PurgeExecutionCommand; use Draw\Component\Console\DependencyInjection\ConsoleIntegration; @@ -60,7 +59,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..d657f217 --- /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" diff --git a/packages/log/composer.json b/packages/log/composer.json index 9d840892..b6d4359c 100644 --- a/packages/log/composer.json +++ b/packages/log/composer.json @@ -16,11 +16,13 @@ }, "require-dev": { "draw/dependency-injection": "^0.11", + "draw/user-bundle": "^0.11", "monolog/monolog": "^3.5.0", "phpunit/phpunit": "^9.0 || ^10.0", "symfony/event-dispatcher": "^6.4.0", "symfony/http-foundation": "^6.4.0", - "symfony/http-kernel": "^6.4.0" + "symfony/http-kernel": "^6.4.0", + "symfony/security-core": "^6.4.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php b/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php index 44f2cccb..9d1264d5 100644 --- a/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php +++ b/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php @@ -17,8 +17,6 @@ use Draw\Component\Mailer\EventListener\EmailSubjectFromHtmlTitleListener; use Draw\Component\Mailer\Twig\TranslationExtension; use PHPUnit\Framework\Attributes\CoversClass; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; -use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -68,8 +66,8 @@ public function testPrependNoFrameworkExtension(): void public function testPrepend(): void { $containerBuilder = new ContainerBuilder(); - $containerBuilder->registerExtension(new FrameworkExtension()); - $containerBuilder->registerExtension(new TwigExtension()); + $containerBuilder->registerExtension($this->mockExtension('framework')); + $containerBuilder->registerExtension($this->mockExtension('twig')); $this->integration->prepend( $containerBuilder, diff --git a/packages/messenger/DependencyInjection/MessengerIntegration.php b/packages/messenger/DependencyInjection/MessengerIntegration.php index 01e9674d..c47b8e80 100644 --- a/packages/messenger/DependencyInjection/MessengerIntegration.php +++ b/packages/messenger/DependencyInjection/MessengerIntegration.php @@ -72,6 +72,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con 'Resources', 'SerializerEventDispatcher', 'Tests', + 'vendor', 'Versioning', ]; diff --git a/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php b/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php index 691f3f81..398be074 100644 --- a/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php +++ b/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php @@ -2,8 +2,6 @@ namespace Draw\Component\Messenger\Tests\DependencyInjection; -use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; -use Draw\Bundle\SonataIntegrationBundle\DependencyInjection\DrawSonataIntegrationExtension; use Draw\Component\DependencyInjection\Integration\IntegrationInterface; use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase; use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration; @@ -39,7 +37,6 @@ use Draw\Contracts\Messenger\EnvelopeFinderInterface; use Draw\Contracts\Messenger\TransportRepositoryInterface; use PHPUnit\Framework\Attributes\CoversClass; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; @@ -404,9 +401,9 @@ function (Definition $definition): void { public function testPrepend(): void { $containerBuilder = new ContainerBuilder(); - $containerBuilder->registerExtension(new DoctrineExtension()); - $containerBuilder->registerExtension(new FrameworkExtension()); - $containerBuilder->registerExtension(new DrawSonataIntegrationExtension()); + $containerBuilder->registerExtension($this->mockExtension('doctrine')); + $containerBuilder->registerExtension($this->mockExtension('framework')); + $containerBuilder->registerExtension($this->mockExtension('draw_sonata_integration')); $this->integration->prepend( $containerBuilder, diff --git a/packages/open-api/composer.json b/packages/open-api/composer.json index a2f5f719..29545426 100644 --- a/packages/open-api/composer.json +++ b/packages/open-api/composer.json @@ -18,6 +18,7 @@ "draw/dependency-injection": "^0.11", "draw/tester": "^0.11", "doctrine/common": "^3.1", + "doctrine/doctrine-bundle": "^2.5", "doctrine/orm": "^2.11", "phpunit/phpunit": "^9.0 || ^10.0", "sensio/framework-extra-bundle": "^5.6 || ^6.2" diff --git a/packages/validator/composer.json b/packages/validator/composer.json index 1df5eda7..dd606f88 100644 --- a/packages/validator/composer.json +++ b/packages/validator/composer.json @@ -14,7 +14,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.0 || ^10.0", - "doctrine/persistence": "^2.2 || ^3.0" + "doctrine/persistence": "^2.2 || ^3.0", + "draw/dependency-injection": "^0.11" }, "minimum-stability": "dev", "prefer-stable": true,