gpt4 book ai didi

php - Laravel 5,Behat,Mink : base_url parameter is not read from behat. yml

转载 作者:可可西里 更新时间:2023-11-01 00:42:38 25 4
gpt4 key购买 nike

我正在使用 Laravel 5BehatLaravel 的 Mink 扩展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'

所以现在我的问题是:为什么 base_url 不是从 behat.yml 文件中读取的?

注意:我也尝试设置 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 - Laravel 5,Behat,Mink : base_url parameter is not read from behat. yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30423211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com