php-Lravel 5,Behat,貂皮:未从behat.yml中读取base_url参数

我正在使用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.

上一篇:php-如何配置Behat从应用程序特定文件夹自动加载类


下一篇:莴苣BDD:如何引用方案?