From b38c5d16590cb297d4de2cf90dad7c214ed0d9e7 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 11:52:02 +0300 Subject: [PATCH 1/8] correct build with PHP 5.5 --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index f837dac..2b4a70d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,17 +17,23 @@ matrix: - php: 7.0 - php: 5.6 - php: 5.5 + dist: trusty - php: 5.5 + dist: trusty env: SYMFONY_VERSION=2.7.* - php: 5.5 + dist: trusty env: SYMFONY_VERSION=2.8.* - php: 5.5 + dist: trusty env: SYMFONY_VERSION=3.4.* - php: 7.1 env: SYMFONY_VERSION=4.1.* PHPUNIT_VERSION=5.7.* - php: 5.5 + dist: trusty env: DOCTRINE_VERSION=2.4.* - php: 5.5 + dist: trusty env: DOCTRINE_VERSION=2.5.* - php: 7.2 env: DOCTRINE_VERSION=2.6.* From eb37b06e071bc5503eb19ef41694719f9131d009 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 11:52:20 +0300 Subject: [PATCH 2/8] test with PHP 7.3 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2b4a70d..2016273 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ branches: matrix: fast_finish: true include: + - php: 7.3 - php: 7.2 - php: 7.1 - php: 7.0 From 1fb00b4246dd8355405c949aa8d4d8ed03f33f98 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 11:52:43 +0300 Subject: [PATCH 3/8] HHVM not longer supported --- .travis.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2016273..9ddaed3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,15 +38,8 @@ matrix: env: DOCTRINE_VERSION=2.5.* - php: 7.2 env: DOCTRINE_VERSION=2.6.* - - php: hhvm - sudo: required - dist: trusty - group: edge - allow_failures: - - php: hhvm before_install: - - if [ "$TRAVIS_PHP_VERSION" = "hhvm" ]; then echo 'xdebug.enable = on' >> /etc/hhvm/php.ini; fi - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi; before_script: From 55a369a3f49a45c326c5d88ef53bad7a59cd26be Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 11:53:57 +0300 Subject: [PATCH 4/8] test with actual Symfony versions 2.8, 3.4, 4.2, 4.3 --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ddaed3..048f0ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,6 @@ matrix: - php: 5.6 - php: 5.5 dist: trusty - - php: 5.5 - dist: trusty - env: SYMFONY_VERSION=2.7.* - php: 5.5 dist: trusty env: SYMFONY_VERSION=2.8.* @@ -29,7 +26,9 @@ matrix: dist: trusty env: SYMFONY_VERSION=3.4.* - php: 7.1 - env: SYMFONY_VERSION=4.1.* PHPUNIT_VERSION=5.7.* + env: SYMFONY_VERSION=4.2.* PHPUNIT_VERSION=5.7.* + - php: 7.1 + env: SYMFONY_VERSION=4.3.* PHPUNIT_VERSION=5.7.* - php: 5.5 dist: trusty env: DOCTRINE_VERSION=2.4.* From 516db30d14322cf9ee5ebd8faff344a779113264 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 11:55:36 +0300 Subject: [PATCH 5/8] fix memory limit error with composer --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 048f0ad..eb7a842 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ before_script: - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --dev --no-update; fi; - if [ "$DOCTRINE_VERSION" != "" ]; then composer require "doctrine/orm:${DOCTRINE_VERSION}" --dev --no-update; fi; - if [ "$PHPUNIT_VERSION" != "" ]; then composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; fi; - - composer install --prefer-dist --no-interaction --no-scripts --no-progress + - COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-interaction --no-scripts --no-progress script: - vendor/bin/phpunit --coverage-clover build/coverage-clover.xml From f3abaea04fd7bb012663255faf9420cacd44c056 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 12:26:41 +0300 Subject: [PATCH 6/8] fix GpsLabDomainEventBundleTest --- src/GpsLabDomainEventBundle.php | 1 - tests/GpsLabDomainEventBundleTest.php | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/GpsLabDomainEventBundle.php b/src/GpsLabDomainEventBundle.php index d5946c2..13f98c6 100644 --- a/src/GpsLabDomainEventBundle.php +++ b/src/GpsLabDomainEventBundle.php @@ -21,7 +21,6 @@ class GpsLabDomainEventBundle extends Bundle */ public function build(ContainerBuilder $container) { - parent::build($container); $container->addCompilerPass(new EventListenerPass()); } diff --git a/tests/GpsLabDomainEventBundleTest.php b/tests/GpsLabDomainEventBundleTest.php index cd007c8..5547bc1 100644 --- a/tests/GpsLabDomainEventBundleTest.php +++ b/tests/GpsLabDomainEventBundleTest.php @@ -22,9 +22,15 @@ class GpsLabDomainEventBundleTest extends \PHPUnit_Framework_TestCase */ private $bundle; + /** + * @var ContainerBuilder + */ + private $container; + protected function setUp() { $this->bundle = new GpsLabDomainEventBundle(); + $this->container = new ContainerBuilder(); } public function testCorrectBundle() @@ -34,21 +40,13 @@ public function testCorrectBundle() public function testBuild() { - if (PHP_VERSION_ID >= 70000) { - $this->markTestSkipped(sprintf('Impossible to mock "%s" on PHP 7', ContainerBuilder::class)); - } + $this->bundle->build($this->container); - /* @var $container \PHPUnit_Framework_MockObject_MockObject|ContainerBuilder */ - $container = $this - ->getMockBuilder(ContainerBuilder::class) - ->disableOriginalConstructor() - ->getMock(); - $container - ->expects($this->once()) - ->method('addCompilerPass') - ->with($this->isInstanceOf(EventListenerPass::class)); - - $this->bundle->build($container); + $has_event_listener_pass = false; + foreach ($this->container->getCompiler()->getPassConfig()->getBeforeOptimizationPasses() as $pass) { + $has_event_listener_pass = $pass instanceof EventListenerPass ?: $has_event_listener_pass; + } + $this->assertTrue($has_event_listener_pass); } public function testContainerExtension() From b49f63b68a32c357f9c5fe5be47191d1580b672d Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 12:35:05 +0300 Subject: [PATCH 7/8] fix GpsLabDomainEventExtensionTest --- .../GpsLabDomainEventExtension.php | 2 +- .../GpsLabDomainEventExtensionTest.php | 103 ++++-------------- 2 files changed, 24 insertions(+), 81 deletions(-) diff --git a/src/DependencyInjection/GpsLabDomainEventExtension.php b/src/DependencyInjection/GpsLabDomainEventExtension.php index ab9a527..a6d4f82 100644 --- a/src/DependencyInjection/GpsLabDomainEventExtension.php +++ b/src/DependencyInjection/GpsLabDomainEventExtension.php @@ -20,7 +20,7 @@ class GpsLabDomainEventExtension extends Extension { /** - * @param array $configs + * @param array $configs * @param ContainerBuilder $container */ public function load(array $configs, ContainerBuilder $container) diff --git a/tests/DependencyInjection/GpsLabDomainEventExtensionTest.php b/tests/DependencyInjection/GpsLabDomainEventExtensionTest.php index 1fd94f7..34f3892 100644 --- a/tests/DependencyInjection/GpsLabDomainEventExtensionTest.php +++ b/tests/DependencyInjection/GpsLabDomainEventExtensionTest.php @@ -14,36 +14,24 @@ use GpsLab\Domain\Event\Bus\EventBus; use GpsLab\Domain\Event\Listener\Subscriber; use GpsLab\Domain\Event\Queue\EventQueue; -use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; class GpsLabDomainEventExtensionTest extends \PHPUnit_Framework_TestCase { - /** - * @var \PHPUnit_Framework_MockObject_MockObject|ContainerBuilder - */ - private $container; - /** * @var GpsLabDomainEventExtension */ private $extension; - const CONTAINER_OFFSET = 13; + /** + * @var ContainerBuilder + */ + private $container; protected function setUp() { - if (PHP_VERSION_ID >= 70000) { - $this->markTestSkipped(sprintf('Impossible to mock "%s" on PHP 7', ContainerBuilder::class)); - } - - $this->container = $this - ->getMockBuilder(ContainerBuilder::class) - ->disableOriginalConstructor() - ->getMock() - ; $this->extension = new GpsLabDomainEventExtension(); + $this->container = new ContainerBuilder(); } /** @@ -115,73 +103,28 @@ public function config() */ public function testLoad(array $config, $bus, $queue, $locator, $publish_on_flush) { - $publisher = $this->getMock(Definition::class); - $publisher - ->expects($this->once()) - ->method('replaceArgument') - ->with(2, $publish_on_flush) - ; + $this->extension->load($config, $this->container); - $this->container - ->expects($this->at(self::CONTAINER_OFFSET)) - ->method('setAlias') - ->with('domain_event.bus', $bus) - ; - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 1)) - ->method('setAlias') - ->with('domain_event.queue', $queue) - ; - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 2)) - ->method('setAlias') - ->with('domain_event.locator', $locator) - ; - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 3)) - ->method('setAlias') - ->with(EventBus::class, $bus) - ; - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 4)) - ->method('setAlias') - ->with(EventQueue::class, $queue) - ; - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 5)) - ->method('getDefinition') - ->with('domain_event.publisher') - ->will($this->returnValue($publisher)) - ; + $this->assertEquals($bus, $this->container->getAlias('domain_event.bus')); + $this->assertEquals($queue, $this->container->getAlias('domain_event.queue')); + $this->assertEquals($locator, $this->container->getAlias('domain_event.locator')); + $this->assertEquals($bus, $this->container->getAlias(EventBus::class)); + $this->assertEquals($queue, $this->container->getAlias(EventQueue::class)); - if (method_exists($this->container, 'registerForAutoconfiguration')) { - $child = $this - ->getMockBuilder(ChildDefinition::class) - ->disableOriginalConstructor() - ->getMock() - ; - $child - ->expects($this->once()) - ->method('addTag') - ->with('domain_event.subscriber') - ->will($this->returnSelf()) - ; - $child - ->expects($this->once()) - ->method('setAutowired') - ->with(true) - ->will($this->returnSelf()) - ; + $publisher = $this->container->getDefinition('domain_event.publisher'); + $this->assertEquals($publish_on_flush, $publisher->getArgument(2)); - $this->container - ->expects($this->at(self::CONTAINER_OFFSET + 6)) - ->method('registerForAutoconfiguration') - ->with(Subscriber::class) - ->will($this->returnValue($child)) - ; + if (method_exists($this->container, 'registerForAutoconfiguration')) { + $has_subscriber = false; + foreach ($this->container->getAutoconfiguredInstanceof() as $key => $definition) { + if ($key === Subscriber::class) { + $has_subscriber = true; + $this->assertTrue($definition->hasTag('domain_event.subscriber')); + $this->assertTrue($definition->isAutowired()); + } + } + $this->assertTrue($has_subscriber); } - - $this->extension->load($config, $this->container); } public function testAlias() From 8b82abd5f524dcdf604ed516301bcce725b94d7e Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Thu, 15 Aug 2019 13:08:03 +0300 Subject: [PATCH 8/8] fix EventListenerPassTest --- tests/DependencyInjection/Compiler/EventListenerPassTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/DependencyInjection/Compiler/EventListenerPassTest.php b/tests/DependencyInjection/Compiler/EventListenerPassTest.php index 1e86c90..6364aa7 100644 --- a/tests/DependencyInjection/Compiler/EventListenerPassTest.php +++ b/tests/DependencyInjection/Compiler/EventListenerPassTest.php @@ -104,6 +104,10 @@ public function testProcessCustomLocator() */ public function locators() { + if (PHP_VERSION_ID >= 70000) { + $this->markTestSkipped(sprintf('Impossible to mock "%s" on PHP 7', Definition::class)); + } + $locator = $this->getMock(Definition::class); return [