如何手动确保用户未在 BDD Behat 场景中登录我的 FeatureContext 类?例如我有这种情况:
Scenario: passing wrong values will not get me in
Given I am on "/login"
And I am not logged in
When I fill in "login" with "KtokolwiekWidzialKtokolwiekWie"
When I fill in "password" with "root_as_allways"
When I press "Login"
Then I should be on "/"
And I should see "Wrong login or password"
我已经定义了这个上下文:
/**
* @Given /^I am not logged in$/
*/
public function iAmNotLoggedIn()
{
# logout currently login user, if any
$request = $this->kernel->getContainer()->get('request');
$request->getSession()->invalidate();
}
但这在运行此功能测试时给了我一个错误。
您不能创建非活动范围(“请求”)的服务(“请求”)。
注意:我使用的是 Symfony 2.1 RC-1