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 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
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.
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
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!
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?
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.
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.
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>