Behat / CommonContexts

Common FeatureContext classes for Behat
116 stars 34 forks source link

fix BehatContext old class use clause #22

Closed cordoval closed 12 years ago

cordoval commented 12 years ago

just missed switching this class as well

I am doing this now, hope it is ok with behat 2.4

public function __construct(array $parameters)
    {
        $this->parameters = $parameters;
        $this->useContext('api', new WebApiContext($parameters['base_url']));
        $this->useContext('symfony_doctrine', new SymfonyDoctrineContext());
        $this->useContext('mink_redirect', new MinkRedirectContext());
        $this->useContext('mink_extra', new MinkExtraContext())
    }

also common-contexts is too small i guess to have a develop branch so I am PR'eing master

stof commented 12 years ago

This is broken. getting the doctrine registry from the behat container will not work. The context need to get it from the Symfony container (accessible thanks to the Symfony2Extension)

cordoval commented 12 years ago

how then should we approach it @stof? I have read what @everzet wrote but so should I work on a custom extension? i mean is there a simpler way to get it working?

stof commented 12 years ago

why a custom extension ? what you need is already provided by the Symfony2Extension, but it need to be used in the context. Btw, trying to use the code would have show you a failure with an invalid service id.

cordoval commented 12 years ago

so i mean is very well possible, i don't have to develop but it is already possible right? just checking

stof commented 12 years ago

yeah, you simply need to update the context totally instead of just changing the base class.

everzet commented 12 years ago

You should just implement KernelAwareInterface and Behat with Symfony2Extension will ensure rest (that this context OR subcontext will actually recieve kernel instance).

cordoval commented 12 years ago

@everzet it is implementing KernelAwareInterface, I am confused

so according to how this is done in the example here:

    $doctrine = $this->kernel->getContainer()->get('doctrine'); ?

so the common context don't work anymore? I am confused

stof commented 12 years ago

@cordoval This is exactly the reason an update is needed

cordoval commented 12 years ago

i guess I copy the code inside the WebAPIContext and plug it into my own like here: https://github.com/Behat/Symfony2Extension/blob/master/testapp/src/Behat/Sf2DemoBundle/Features/Context/WebContext.php

but then how to call it from within my FeatureContext? just use it like a boss? that is amazing, or am i still confused? can you do a line of how to use it?

cordoval commented 12 years ago

is this how you import the context? @web ? I mean i have a set of several contexts to which DIC passes the kernel i write my own steps in each of these contexts and on myfeat.feature i write on each @web, @specialized etc etc that is the way one uses it?

also second question is how to use a meta step in one context borrowed from another context?

cordoval commented 12 years ago

oh wow i will experiment, just saw your behat.yml https://github.com/Behat/Symfony2Extension/blob/master/testapp/behat.yml amazing @everzet, cool man good job, there are hidden gems to be exposed there

cordoval commented 12 years ago

I think i figured it out @everzet will you let me port at least one of the Contexts? I will go ahead and send PR