与水貂相处
有谁知道如何成功配置 Mink 以与 Behat 一起使用?如果有人不知道,Behat 是一个 PHP 的 BDD(行为驱动开发)框架,Mink 提供了一个浏览器模拟器抽象层来测试。
您可以在 http://behat.org/ 找到有关 Behat 的更多信息,在 https://github.com/Behat/Mink 或 http://www.knplabs.com/fr/blog/one-mink-to-rule-them-all
基本上我按照 http://www.knplabs.com 上的说明进行操作/fr/blog/one-mink-to-rule-them-all 配置我的 Mink 以与我的 Behat 配合使用。我的 behat.yml 位于 Behat 文件夹中,而不是 Mink 文件夹中,如下所示:
default:
paths:
features: %%BEHAT_CONFIG_PATH%%/features
formatter:
name: progress
pretty:
formatter:
name: pretty
parameters:
multiline_arguments: false
default:
environment:
parameters:
start_url: http://localhost/
imports:
- mink/behat.yml
我的 features/support/boostrap.php
require_once 'mink/autoload.php';
但是,在我的 features/support/env.php 中包含以下代码
$world->client = new \Goutte\Client;
会给我一个 PHP Fatal error: Class 'Goutte\Client' not found interminal(OSX )当我使用 behat 命令时。即使我的 behat/Mink/Vendor/Goutte 文件夹中有 goutte.phar 也会发生这种情况。
希望任何人都能启发我,让我知道我哪里出错了,如果问题中有任何部分我不清楚,请告诉我。多谢。
Does anyone know how to successfully configure Mink to work with Behat? In case if anyone doesn't know, Behat is a BDD(Behaviour-Driven Development) framework for PHP and Mink provides a browser emulators abstraction layer to test with.
You can find out more about Behat at http://behat.org/ and Mink at https://github.com/Behat/Mink or http://www.knplabs.com/fr/blog/one-mink-to-rule-them-all
Basically i followed the instructions at http://www.knplabs.com/fr/blog/one-mink-to-rule-them-all to configure my Mink to work with my Behat. My behat.yml, the one located inside the Behat folder, not the Mink folder, is as follows:
default:
paths:
features: %%BEHAT_CONFIG_PATH%%/features
formatter:
name: progress
pretty:
formatter:
name: pretty
parameters:
multiline_arguments: false
default:
environment:
parameters:
start_url: http://localhost/
imports:
- mink/behat.yml
I also have the following code in my features/support/boostrap.php
require_once 'mink/autoload.php';
However, having the following code in my features/support/env.php
$world->client = new \Goutte\Client;
would give me a PHP Fatal error: Class 'Goutte\Client' not found in terminal(OSX) when i use the behat command. This happens even if i have the goutte.phar inside my behat/Mink/Vendor/Goutte folder.
Hope anyone can enlighten me on where i went wrong and if there was any part in the question where I wasn't being clear about it, do let me know. Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是: https://github.com/knplabs/mink-demo ;-)
基本上,使用 Mink,您不需要创建或要求 Goutte 客户端,它由 Mink 自动完成。您的 $world 也得到了增强,现在您可以在步骤定义中获取 mink 会话:
此外,您还忘记包含 PHPUnit!
请参阅 mink-demo 以获得很好的示例;-)
Here it is: https://github.com/knplabs/mink-demo ;-)
Basically, with Mink, you don't need to create or require Goutte client it's done by Mink automatically. Your $world was also enhanced and now you're able to get mink session inside step definitions:
Also, you've forgot to include PHPUnit!
See mink-demo for getting great example ;-)