I am trying to set-up Behat but it fails to init when I run bin/behat --init
. My composer.json
is taken from the official docs:
{
"require": {
"behat/behat": "2.4.*@stable",
"behat/mink": "1.4.*@stable",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
The composer install
works fine and looks like all dependencies get installed.
# behat.yml
default:
paths:
features: features
bootstrap: features/bootstrap
extensions:
Behat\MinkExtension\Extension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2: ~
annotations:
paths:
features: features/annotations
closures:
paths:
features: features/closures
Running # bin/behat --init
yields the following error:
PHP Strict Standards: Declaration of Behat\Mink\Driver\Goutte\Client::createResponse() should be compatible with Goutte\Client::createResponse(GuzzleHttp\Message\Response $response) in /web/Test-1/vendor/behat/mink-goutte-driver/src/Behat/Mink/Driver/Goutte/Client.php on line 23
Strict Standards: Declaration of Behat\Mink\Driver\Goutte\Client::createResponse() should be compatible with Goutte\Client::createResponse(GuzzleHttp\Message\Response $response) in /web/Test-1/vendor/behat/mink-goutte-driver/src/Behat/Mink/Driver/Goutte/Client.php on line 23
[ReflectionException]
Class Guzzle\Http\Client does not exist
Could somebody tell me why? I did everything exactly like in official article.
You are using incompatible versions of Mink extensions / drivers. The following pulls the latest versions compatible (right now) with Behat 3 and Mink 1.6, while you want to use much older versions (2.4.* and 1.4.* respectively).
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
I am assuming you've pulled this from the Internet, as I can't find a different example out there with fixed versions, which is pretty ironic, as the same people are probably blogging at the same time about how much of a bad practice that is. If you are just beginning, I suggest you stick with the latest versions of Behat and Mink, they are much better and have been more than stable for the past 6 months. Change you composer.json and update the dependencies:
"behat/behat": "*",
"behat/mink": "*"
If not, go to each extension / driver repo and find the tagged version from early-mid 2013, that should fix it for the older packages.
Update
The code you provided doesn't work because you are using the old config format with the new Behat / Mink version. Don't forget, Behat 2 configs must be upgraded for Behat 3. Documentation is still pretty poor, but the basics are covered rather well here and here. Updating your config to this resolves the issue:
default:
extensions:
Behat\MinkExtension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2: ~
suites:
default:
paths:
- '%paths.base%/features'
annotations:
paths:
- '%paths.base%/features/annotations'
closures:
paths:
- '%paths.base%/features/closures'
Here are the the packed files, just in case you get lost, the init command produces this:
Ian-Bytcheks-MacBook-Pro:behat ianbytchek$ php ./vendor/bin/behat --init
+d features - place your *.feature files here
+d features/bootstrap - place your context classes here
+f features/bootstrap/FeatureContext.php - place your definitions, transformations and hooks here
+d features/annotations - place your *.feature files here
+d features/closures - place your *.feature files here
Update
The root of all evil was the curl module, that was not installed in the author's environment. Instead of a proper warning php tried to mitigate the problem by using an alternative, which didn't help much.