如何在 Cake Php 中使用 Behat?

问题描述

我有这个功能

功能用户访问约会仪表板

Scenario:
Given I am on "User Dashboard Page"
And I should see "APPOINTMENTS"
And I should see "PRE-ENROLMENTS"
When I press "APPOINTMENTS"
Then I am on "Appointments Dashboard"
And I should see "Booking Reference"
And I should see "Book Another Appointment"

我有这些步骤

--- FeatureContext 缺少步骤。使用以下代码段定义它们:

/**
 * @Given I am on :arg1
 */
public function iAmOn($arg1)
{
    throw new PendingException();
}

/**
 * @Given I should see :arg1
 */
public function iShouldSee($arg1)
{
    throw new PendingException();
}

/**
 * @When I press :arg1
 */
public function iPress($arg1)
{
    throw new PendingException();
}

我如何完成这些步骤并在 Cake PHP 中使用 Behat 运行它? 所以,我的测试通过了 ??

解决方法

如果您想访问您的 CakePHP 内部结构,那么您可能希望在您的上下文中拥有一个 CakePHP 应用程序的实例(例如 App\ApplicationCake\Http\Server,看看你的 index.php 就完成了)。然后,希望您能够通过 CakePHP 的默认 Service Container 访问所有常用的应用程序内部。