我试过谷歌这个,但我找不到答案,所以我在这里张贴。
我正在使用PHP5.5.9在Cloud9 IDE上尝试共同欺骗2.1.5,研究编写验收测试,并配置我的acceptance.suite.yml文件。
我试图在PhpBrowser提出的请求中包含一个cookie,如欺骗PhpBrowser页面所描述的那样。我想我可以用acceptance.suite.yml中的“cookie”设置来完成这个任务。
acceptance.suite.yml
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: https://dm1-cboudreausf.c9users.io
cookies:
c9_user_cookie:
Name: c9.live.user.sso
Value: somevaluehere
Path: /
Domain: .c9users.io
- \Helper\Acceptance这是我的HomepageCept.php:
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure the homepage renders correctly');
$I->amOnPage('/');
$I->see('welcome');但是,当我在调试模式下运行测试时,如下所示:
php codecept.phar run --debug我可以看到没有请求饼干:
Ensure the homepage renders correctly (HomepageCept)
Scenario:
* I am on page "/"
[Page] /
[Response] 302
[Request Cookies] []
[Response Headers] {"Location":["https://c9users.io/_user_content/authorize?redirect=https%3A%2F%2Fdm1-cboudreausf.c9users.io%2F"],"Date":["Mon, 21 Dec 2015 22:38:44 GMT"],"Transfer-Encoding":["chunked"],"X-BACKEND":["apps-proxy"],"Content-Type":["text/html"]}
[Redirecting to] https://c9users.io/_user_content/authorize?redirect=https%3A%2F%2Fdm1-cboudreausf.c9users.io%2F正确的语法是什么??
发布于 2015-12-22 11:45:47
Cookie参数不是由PhpBrowser处理,而是传递给。
如果运行测试和PHP5.4,则使用guese5.3,http://docs.guzzlephp.org/en/5.3/clients.html?highlight=cookies
Types: bool / array / GuzzleHttp\Cookie\CookieJarInterface
我不知道您使用的格式是否适用于guese5.3,但是键值对应该可以工作。
cookies: 'c9.live.user.sso': 'somevaluehere'
如果您在较新版本的PHP上运行测试,那么您可能使用guese6 http://docs.guzzlephp.org/en/latest/request-options.html#cookies。
You must specify the cookies option as a GuzzleHttp\Cookie\CookieJarInterface or false.
我看不出cookies选项可以使用guese6,所以我在Github:https://github.com/Codeception/Codeception/issues/2653中提出了这个问题。
https://stackoverflow.com/questions/34405890
复制相似问题