我正在处理的项目在登录后面有一个api。我如何使用Behat和Mink和WebApiContext?
我使用贝哈特水貂登录:
Scenario: Login
Given I am on "/login/"
And I should see "Login"
When I fill in "_username" with "test"
And I fill in "_password" with "test"
And I press "_submit"
Then I should be on "/"
该工程..
然而,登录会话没有存储每当我想要做的使用WebApiContext如下:
Scenario: Getting the list of pages
When I send a GET request to "/api/pages.json"
Then print response
我在同一功能中使用了这两种方案。我FeatureContext类看起来是这样的:
class FeatureContext extends MinkContext
{
public function __construct(array $parameters)
{
$context = new WebApiContext($parameters['base_url']);
$context->getBrowser()->getClient()->setCookieJar(new \Buzz\Util\CookieJar());
$this->useContext('web', $context);
}
}
我加入了cookiejar想法来自this issue没有成功。当我打印的回应,我刚才看到的HTML页面从登录屏幕..
没有人有任何想法,如果我要完全错误的方式,或者我有点朝着正确的方向?
不能希望有更好的答案!非常感谢! –