Behat/Mink support for BDD?

Hi guys. I dont know if you know Behat. With Behat you can write test in natural language. And with Mink (a browser), you can run functional tests like

Scenario: User Activated can login

Given exists an activated user called "mario" with email "mario@mario.it" and password "password"

And I am on "/login"

When I fill in "Username" with "mario"

And I fill in "Password" with "password"

And I press "Login"

Then the response should contain "Welcome, mario!"

Hi again sensorario, just gonna add this is based off Ruby’s cucumber project.

Why not write an extension / demonstration / tutorial / whatever - so that we can see how Behat and Mink works with Yii ?

If it’s succesful, then chances are higher that it will make it’s way into the official Yii package. :)

jacmoe, can you help me in this stuff? I’ve tryied. I can share the project on github.

Can you share an example of the introduction of behat into Yii?

I have problems with include-warnings, like




Warning: include(): Failed opening 'PHPUnit_Framework_Comparator_MockObject.php'



hi guys, just noticed that there is Behat / YiiExtension in the official Behat github account, it looks like demostration of how to integrate behat with “other frameworks” (see this everzet’s post) rather than ready-to-use yii extension, but anyway it should help you

btw, I didn’t use behat with yii, but it shouldn’t be a problem just to run behat on yii project: you just need to configure autoloader and provide yii app instance for the behat context

Tryin to integrate behat yii extension without luck :confused:

Yes! Me too.

Have anyone made any progress on this? If not I’ll get into it as well, missing a nice BDD testing framework for my Yii projects. I use it as a standard over my django projects.

Take a look at the YiiBoilerplate wiki article: http://www.yiiframework.com/wiki/374/yiiboilerplate-setup-a-professional-project-structure-in-seconds/

There isn’t much info on Behat (you have to understand it / teach yourself how to use it), but the Boilerplate has Behat pre-setup and ready to use, along with all the Mink drivers

+1 this. I’ve managed to setup behat by looking at the yiiboilerplate code and following behat’s excellent guide http://docs.behat.org/#quick-intro

Couldn’t get it to work with Selenium2. Sahi on the other hand works well and it seems like the better choice.

Can you share a recipe for integrating Behat into Yii? I’m interested in Mink but will go for complete Behat.

Thanks.

I’d actually recommend using Codeception these days (http://codeception.com). It runs over top of Behat / Mink and has fairly decent Yii support (and at least partial backing of some well known Yii guys).

thanks, but all I need is Mink so in effect all technically needed, to the best of my understanding, is to put the Mink tree in some location, then make the two auto loaders sing along and viola! :slight_smile:

Unfortunately, I don’t have the resources to learn what Codeception is, how to work with it, and little less importantly, a desire to integrate all the Codeception into Yii just to get Mink.

Or maybe did I miss your point? Can you point me (or share here) your instructions on integrating Mink (or even Behat) into Yii?

Thanks for the suggestion anyway.

Frustrating…

Sadly, I don’t have any instructions on integrating Mink and I did Behat stuff about 9 months ago, it wasn’t working perfectly and I don’t remember very clearly what I did :-). Hence the suggestion about Codeception, as they have good instructions and handle a lot of that for you.

ok. thanks for the update.

any quick tips/pointers regarding integrating codeception into Yii?

Check basic app, there are some tests.

Thanks @samdark but unfortunately this didn’t help.

I think the complication stems from that composer autoloader. I’m unfamiliar with composer (inexperienced with) and its simply a bite to big to swallow, I guess.

What’s the problem exactly? You have trouble getting basic app to run?

Success!

I have managed to get Mink working in Yii by including vendor/autoload.php and then fully qualify a couple of classes I needed to instantiate on my code. The rest of the classes Mink needed were found by it automatically. So I now have it working.

@Samdark do you mean basic yii app? basic Mink app? (via composer, for example). Yii if obviously working and I’ve created an extension to encapsulate Mink integration details but after including Mink’s autoloader like this (and I’ve tried many many other options… )


$driver = new SahiDriver('phantomjs');

It didn’t work and I got an exception (IIRC) from php that complained that it could not locate the SahiDriver class.

After I changed the instantiation to fully qualified identifier with namespace, it worked:


$driver = new Behat\Mink\Driver\SahiDriver('phantomjs');

EDIT: just to complete the information, the other needed line is a ‘require’ statement:


</div><div>// obviously - update to your path</div><div>require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';</div><div>