This repository was archived by the owner on Feb 5, 2021. It is now read-only.
Description (As @pamil requested, posting it here):
I noticed that when you have two (or more) services of the same class, only the last one seems to take effect.
Config in behat.yml.dist:
....
default:
extensions:
FriendsOfBehat\ContextServiceExtension:
imports:
- "vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml"
- "tests/Behat/Resources/contexts.yml"
- "tests/Behat/Resources/pages.yml"
...
cached:
extensions:
FriendsOfBehat\ContextServiceExtension:
imports:
- "vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml"
Steps to reproduce:
1.) Create a class
namespace Tests\Behat\Context\Hook;
use Behat\Behat\Context\Context;
/**
* @author Wojciech Górski <wojciech.gorski@bitbag.pl>
*/
class Something implements Context
{
/**
* @var string
*/
private $message;
/**
* @param string $message
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* @BeforeScenario
*/
public function doThings()
{
echo 'Does things for: ' . $this->message;
}
}
2.) In my Resources/contexts/hook.yml:
something_first:
class: Tests\Behat\Context\Hook\Something
arguments: ["first"]
tags:
- { name: fob.context_service }
something_second:
class: Tests\Behat\Context\Hook\Something
arguments: ["second"]
tags:
- { name: fob.context_service }
3.) Now hook them up within the contexts_services:
- something_first
- something_second
4.) Now when I run my tests I can only see output for the something_second service ("Does things for: second")
Reactions are currently unavailable