From 15f70c0a14bf922b7f6263431a330d6f82883e90 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 9 Dec 2019 12:01:38 +0100 Subject: [PATCH 1/4] Fix the build & add tests for Symfony 4.3 and 4.4 --- .travis.yml | 3 +++ composer.json | 1 + 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4b4e47e..afc7625 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ env: - SYMFONY_VERSION=3.4.* - SYMFONY_VERSION=4.1.* - SYMFONY_VERSION=4.2.* + - SYMFONY_VERSION=4.3.* + - SYMFONY_VERSION=4.4.* cache: directories: @@ -22,6 +24,7 @@ install: - composer require symfony/http-kernel:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer require symfony/proxy-manager-bridge:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer require --dev symfony/framework-bundle:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist + - composer require --dev symfony/process:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer require --dev symfony/yaml:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer update --prefer-dist diff --git a/composer.json b/composer.json index 48dd97c..e772b39 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "phpstan/phpstan-shim": "^0.11", "sylius-labs/coding-standard": "^3.0", "symfony/framework-bundle": "^3.4|^4.1", + "symfony/process": "^3.4|^4.1", "symfony/yaml": "^3.4|^4.1" }, "suggest": { From 5519b92883f39ad837d87c6a23d3b5efd7395958 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 9 Dec 2019 12:36:00 +0100 Subject: [PATCH 2/4] Add conflict with symfony/stopwatch ^5.0 symfony/http-kernel 4.1.* and 4.2.* causes fatal error when symfony/stopwatch 5.0.* is installed --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index e772b39..576a1fc 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,9 @@ "symfony/process": "^3.4|^4.1", "symfony/yaml": "^3.4|^4.1" }, + "conflict": { + "symfony/stopwatch": "^5.0" + }, "suggest": { "behat/mink-browserkit-driver": "^1.3" }, From 06104478cc42cb021e27f8cba32d18904bd5ad92 Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Sun, 8 Dec 2019 23:30:09 +0300 Subject: [PATCH 3/4] Fix referencing context initializers With definition, that has been used instead of reference, container has used to created 2 instances of initializer: one with service id, and one "anonymous", described by spl_object_hash in a container, it breaked stateful initializers: in my case initializer was also used to reset state before next scenario/example, and initializing and resetting happened with different instances of initializer --- .../context_initializer_instantiation.feature | 89 +++++++++++++++++++ src/ServiceContainer/SymfonyExtension.php | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 features/sanity_checks/context_initializer_instantiation.feature diff --git a/features/sanity_checks/context_initializer_instantiation.feature b/features/sanity_checks/context_initializer_instantiation.feature new file mode 100644 index 0000000..c4e5fd4 --- /dev/null +++ b/features/sanity_checks/context_initializer_instantiation.feature @@ -0,0 +1,89 @@ +Feature: instantiation of a context initializer + I want container to only keep 1 instance of context initializer + (if it's a shared service) so it can work correctly if it's stateful + + Scenario: + Given a working Symfony application with SymfonyExtension configured + And a Behat configuration containing: + """ + default: + extensions: + FriendsOfBehat\ServiceContainerExtension: + imports: + - "tests/context_initializer.yml" + + suites: + default: + contexts: + - App\Tests\SomeContext + """ + And a Behat services definition file "tests/context_initializer.yml" containing: + """ + services: + test.initializer: + class: App\Tests\CustomContextInitializer + tags: ["context.initializer", "event_dispatcher.subscriber"] + """ + And a Behat service implementation file "tests/CustomContextInitializer.php" containing: + """ + makeItPass(true); + } + + public static function getSubscribedEvents() + { + return []; + } + } + """ + And a feature file containing: + """ + Feature: + Scenario: + Then it should pass + """ + And a context file "tests/SomeContext.php" containing: + """ + shouldPass = $shouldPass; + } + + /** @Then it should pass */ + public function itShouldPass(): void + { + $actualInitializersCount = CustomContextInitializer::$counter; + assert(1 === $actualInitializersCount, "$actualInitializersCount initializers were created"); + assert($this->shouldPass === true); + } + } + """ + When I run Behat + Then it should pass diff --git a/src/ServiceContainer/SymfonyExtension.php b/src/ServiceContainer/SymfonyExtension.php index 5eac28b..2051d38 100644 --- a/src/ServiceContainer/SymfonyExtension.php +++ b/src/ServiceContainer/SymfonyExtension.php @@ -182,7 +182,7 @@ final class SymfonyExtension implements Extension { $definition = $container->findDefinition('fob_symfony.environment_handler.context_service'); foreach ($container->findTaggedServiceIds(ContextExtension::INITIALIZER_TAG) as $serviceId => $tags) { - $definition->addMethodCall('registerContextInitializer', [$container->getDefinition($serviceId)]); + $definition->addMethodCall('registerContextInitializer', [new Reference($serviceId)]); } } From 9c6c019c6d1c67208261bf183a3effa94357aff4 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 9 Dec 2019 13:08:43 +0100 Subject: [PATCH 4/4] Generate changelog for v2.0.10 --- CHANGELOG-2.0.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG-2.0.md b/CHANGELOG-2.0.md index f4b852d..1c68d67 100644 --- a/CHANGELOG-2.0.md +++ b/CHANGELOG-2.0.md @@ -1,5 +1,10 @@ # CHANGELOG for `2.0.x` +## v2.0.10 (2019-12-09) + +- [#101](https://github.com/FriendsOfBehat/SymfonyExtension/issues/101) Fix referencing context initializers ([@kamazee](https://github.com/kamazee)) +- [#102](https://github.com/FriendsOfBehat/SymfonyExtension/issues/102) Fix the build & add tests for Symfony 4.3 and 4.4 ([@pamil](https://github.com/pamil)) + ## v2.0.9 (2019-10-10) - [#77](https://github.com/FriendsOfBehat/SymfonyExtension/issues/77) Fix docs: change 'kernel.file' to 'kernel.path' ([@mkilmanas](https://github.com/mkilmanas))