我正在使用Laravel 5,Behat和Mink Extension for Laravel.用于安装组件的composer.json片段是:
"require-dev": {
"PHPunit/PHPunit": "~4.0",
"behat/behat": "^3.0",
"behat/mink": "^1.6",
"behat/mink-extension": "^2.0",
"laracasts/behat-laravel-extension": "^1.0"
}
我在behat.yml中设置了基本URL,即文件的全部内容:
default:
extensions:
Laracasts\Behat:
# env_path: .env.behat
Behat\MinkExtension:
base_url: http://localhost/leaveTracker/public
default_session: laravel
laravel: ~
请注意,我在此处将base_url设置为:
base_url: http://localhost/leaveTracker/public
我也写了这个示例功能:
Feature: Viewing the list of employees
In order to operate the employees' data
As a user
I need to see the list of employees
Scenario: I have the option to add employee
Given I am on page "/employee"
Then the current URL should be "http://localhost/leaveTracker/public/employee"
FeatureContext.PHP的相应部分是:
/**
* @Then the current URL should be :arg1
*/
public function theCurrentUrlShouldBe($arg1)
{
PHPUnit::fail($this->getSession()->getcurrenturl());
}
Scenario: I have the option to add employee
Given I am on page "/employee"
Then the current URL should be "http://localhost/leaveTracker/public/employee"
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/employee'
+'http://localhost/leaveTracker/public/employee'
所以现在我的问题是:为什么不从behat.yml文件读取base_url?
注意:我也尝试设置base_url:https://test.com,但是它需要http:// localhost / employee
解决方法:
从Behat 2.x更新到Behat 3.x时遇到了类似的问题
behat.yml:[定义base_url]
extensions:
Behat\MinkExtension:
base_url: 'http://localhost/index.PHP'
在从RawMinkContext调用扩展的Context类中:
$this->visitPath($url);
该函数将$config [‘base_url’]与$url结合在一起.调用$this-> getSession()-> visit($url)浏览到普通的$url.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。