Skip to content

Commit

Permalink
Update for CI & fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
ogizanagi committed May 30, 2018
1 parent b04cc9e commit f9ba543
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Expand Up @@ -45,7 +45,12 @@ jobs:
- php: 7.1
env: stability=RC SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*"
install:
- composer config minimum-stability RC
- travis_retry composer update -n --prefer-dist

- php: 7.1
env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.1.*"
install:
- composer require --dev "symfony/messenger" --no-update
- travis_retry composer update -n --prefer-dist

- php: 7.2
Expand Down
10 changes: 6 additions & 4 deletions DependencyInjection/Compiler/MessengerPass.php
Expand Up @@ -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');
}
}
22 changes: 16 additions & 6 deletions Tests/DependencyInjection/Compiler/MessengerPassTest.php
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 2 additions & 4 deletions composer.json
Expand Up @@ -42,8 +42,7 @@
"twig/twig": "~1.26|~2.0",
"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/web-profiler-bundle": "~2.7|~3.0|~4.0"
},
"conflict": {
"symfony/http-foundation": "<2.6"
Expand All @@ -62,6 +61,5 @@
"branch-alias": {
"dev-master": "1.9.x-dev"
}
},
"minimum-stability": "dev"
}
}

0 comments on commit f9ba543

Please sign in to comment.