Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with multiple services using the same class #21

Closed
ghost opened this issue Aug 8, 2017 · 3 comments
Closed

Problem with multiple services using the same class #21

ghost opened this issue Aug 8, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Aug 8, 2017

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 <[email protected]>
 */
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 }

Now hook them up within the contexts_services:

- something_first
- something_second

Now when I run my tests I can only see output for the something_second service ("Does things for: second")

@pamil
Copy link
Member

pamil commented Aug 8, 2017

It looks like ContextServiceExtension's issue, can you report it there? :)

@ghost
Copy link
Author

ghost commented Aug 8, 2017

Done.

@ghost
Copy link
Author

ghost commented Aug 13, 2017

@ghost ghost closed this as completed Aug 13, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant