Merge branch '2.0'
* 2.0: Generate changelog for v2.0.10 Fix referencing context initializers Add conflict with symfony/stopwatch ^5.0 Fix the build & add tests for Symfony 4.3 and 4.4
This commit is contained in:
@@ -9,6 +9,7 @@ env:
|
||||
- SYMFONY_VERSION=3.4.*
|
||||
- SYMFONY_VERSION=4.2.*
|
||||
- SYMFONY_VERSION=4.3.*
|
||||
- SYMFONY_VERSION=4.4.*
|
||||
|
||||
cache:
|
||||
directories:
|
||||
@@ -23,6 +24,7 @@ install:
|
||||
- composer require symfony/proxy-manager-bridge:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
|
||||
- composer require --dev symfony/browser-kit:${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
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -27,8 +27,12 @@
|
||||
"sylius-labs/coding-standard": "^3.0",
|
||||
"symfony/browser-kit": "^3.4|^4.2",
|
||||
"symfony/framework-bundle": "^3.4|^4.2",
|
||||
"symfony/process": "^3.4|^4.2",
|
||||
"symfony/yaml": "^3.4|^4.2"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/stopwatch": "^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"behat/mink-browserkit-driver": "^1.3"
|
||||
},
|
||||
|
||||
@@ -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:
|
||||
"""
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Context\Initializer\ContextInitializer;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class CustomContextInitializer implements ContextInitializer, EventSubscriberInterface
|
||||
{
|
||||
public static $counter = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
++self::$counter;
|
||||
}
|
||||
|
||||
public function initializeContext(Context $context): void
|
||||
{
|
||||
$context->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:
|
||||
"""
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
|
||||
final class SomeContext implements Context {
|
||||
private $shouldPass = false;
|
||||
|
||||
public function makeItPass(bool $shouldPass)
|
||||
{
|
||||
$this->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
|
||||
@@ -189,7 +189,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)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user