From ca8c4877636490aba5e0b372f11988360c6d210c Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Mon, 14 May 2018 12:06:05 +0200 Subject: [PATCH] Update for CI & fix CS --- .travis.yml | 15 +++++++++++-- .../Compiler/MessengerPass.php | 10 +++++---- .../Compiler/MessengerPassTest.php | 22 ++++++++++++++----- .../DoctrineExtensionTest.php | 5 +++++ composer.json | 5 ++--- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c9821d88..89d9d6deb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,18 +34,29 @@ jobs: - php: 5.5 env: deps=low SYMFONY_DEPRECATIONS_HELPER=weak install: + - composer remove --dev "symfony/messenger" --no-update - travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist - php: 5.6 env: SYMFONY_VERSION="2.8.*" + install: + - composer remove --dev "symfony/messenger" --no-update - php: 7.0 env: SYMFONY_VERSION="3.2.*" + install: + - composer remove --dev "symfony/messenger" --no-update + + - php: 7.1 + env: SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*" + install: + - composer remove --dev "symfony/messenger" --no-update + - travis_retry composer update -n --prefer-dist - php: 7.1 - env: stability=RC SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*" + env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="^4.1@beta" install: - - composer config minimum-stability RC + - composer config minimum-stability dev - travis_retry composer update -n --prefer-dist - php: 7.2 diff --git a/DependencyInjection/Compiler/MessengerPass.php b/DependencyInjection/Compiler/MessengerPass.php index 1d51e0f66..1ee532430 100644 --- a/DependencyInjection/Compiler/MessengerPass.php +++ b/DependencyInjection/Compiler/MessengerPass.php @@ -16,10 +16,12 @@ class MessengerPass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - // Remove wired services if the Messenger component actually isn't enabled: - if (!$container->hasAlias('message_bus') || !is_subclass_of($container->findDefinition('message_bus')->getClass(), MessageBusInterface::class)) { - $container->removeDefinition('doctrine.orm.messenger.middleware_factory.transaction'); - $container->removeDefinition('messenger.middleware.doctrine_transaction_middleware'); + if ($container->hasAlias('message_bus') && is_subclass_of($container->findDefinition('message_bus')->getClass(), MessageBusInterface::class)) { + return; } + + // Remove wired services if the Messenger component actually isn't enabled: + $container->removeDefinition('doctrine.orm.messenger.middleware_factory.transaction'); + $container->removeDefinition('messenger.middleware.doctrine_transaction_middleware'); } } diff --git a/Tests/DependencyInjection/Compiler/MessengerPassTest.php b/Tests/DependencyInjection/Compiler/MessengerPassTest.php index a39d3bdec..968a5e4ba 100644 --- a/Tests/DependencyInjection/Compiler/MessengerPassTest.php +++ b/Tests/DependencyInjection/Compiler/MessengerPassTest.php @@ -8,14 +8,24 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Messenger\MessageBus; +use Symfony\Component\Messenger\MessageBusInterface; class MessengerPassTest extends TestCase { + protected function setUp() + { + if (interface_exists(MessageBusInterface::class)) { + return; + } + + $this->markTestSkipped('Symfony Messenger component is not installed'); + } + public function testRemovesDefinitionsWhenMessengerComponentIsDisabled() { - $pass = new MessengerPass(); + $pass = new MessengerPass(); $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); $loader->load('messenger.xml'); $pass->process($container); @@ -26,9 +36,9 @@ public function testRemovesDefinitionsWhenMessengerComponentIsDisabled() public function testRemoveDefinitionsWhenHasAliasButNotMessengerComponent() { - $pass = new MessengerPass(); + $pass = new MessengerPass(); $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); $loader->load('messenger.xml'); $container->register('some_other_bus', \stdClass::class); @@ -42,9 +52,9 @@ public function testRemoveDefinitionsWhenHasAliasButNotMessengerComponent() public function testDoesNotRemoveDefinitionsWhenMessengerComponentIsEnabled() { - $pass = new MessengerPass(); + $pass = new MessengerPass(); $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); $loader->load('messenger.xml'); $container->register('messenger.bus.default', MessageBus::class); diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 3803a8c2c..408dca345 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -18,6 +18,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\Messenger\MessageBusInterface; class DoctrineExtensionTest extends TestCase { @@ -678,6 +679,10 @@ public function testAnnotationsBundleMappingDetectionWithVendorNamespace() public function testMessengerIntegration() { + if (! interface_exists(MessageBusInterface::class)) { + $this->markTestSkipped('Symfony Messenger component is not installed'); + } + $container = $this->getContainer(); $extension = new DoctrineExtension(); diff --git a/composer.json b/composer.json index 0ca83e232..f0a181767 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "satooshi/php-coveralls": "^1.0", "phpunit/phpunit": "^4.8.36|^5.7|^6.4", "symfony/web-profiler-bundle": "~2.7|~3.0|~4.0", - "symfony/messenger": "~4.1-beta2" + "symfony/messenger": "^4.1@beta" }, "conflict": { "symfony/http-foundation": "<2.6" @@ -62,6 +62,5 @@ "branch-alias": { "dev-master": "1.9.x-dev" } - }, - "minimum-stability": "dev" + } }