我正在尝试设置Behat但是当我运行bin/behat --init
时它无法初始化。我的composer.json
取自官方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/"
}
}
composer install
工作正常,看起来所有依赖项都已安装。
# 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
运行# bin/behat --init
会产生以下错误:
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
有人可以告诉我为什么吗? 我在官方文章中做了一切。
答案 0 :(得分:1)
您正在使用不兼容的Mink扩展程序/驱动程序版本。下面介绍与Behat 3和Mink 1.6兼容的最新版本(现在),而你想使用更旧版本(分别为2.4。*和1.4。*)。
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
我假设你已经从互联网上删除了这个,因为我找不到具有固定版本的不同例子,这很讽刺,因为同样的人可能同时写博客关于有多糟糕的做法。如果你刚刚开始,我建议你坚持使用最新版本的Behat和Mink,它们要好得多,并且在过去的6个月里一直保持稳定。更改您的composer.json并更新依赖项:
"behat/behat": "*",
"behat/mink": "*"
如果没有,请转到每个扩展程序/驱动程序仓库,并从2013年中期开始查找已标记的版本,该版本应修复较旧的软件包。
<强>更新强>
您提供的代码无效,因为您使用旧的配置格式和新的Behat / Mink版本。不要忘记,必须为Behat 3升级Behat 2配置。Documentation仍然相当差,但基本功能涵盖得相当好here和here。将配置更新为此可以解决问题:
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'
以下是打包的files,以防你迷路,init命令产生这个:
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
<强>更新强>
所有邪恶的根源是curl模块,它没有安装在作者的环境中。而不是一个正确的警告php试图通过使用替代方案来缓解问题,而这并没有多大帮助。