首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在欺骗的PhpBrowser acceptance.suite.yml中使用“cookie”设置?

如何在欺骗的PhpBrowser acceptance.suite.yml中使用“cookie”设置?
EN

Stack Overflow用户
提问于 2015-12-21 23:06:31
回答 1查看 1.3K关注 0票数 1

我试过谷歌这个,但我找不到答案,所以我在这里张贴。

我正在使用PHP5.5.9在Cloud9 IDE上尝试共同欺骗2.1.5,研究编写验收测试,并配置我的acceptance.suite.yml文件。

我试图在PhpBrowser提出的请求中包含一个cookie,如欺骗PhpBrowser页面所描述的那样。我想我可以用acceptance.suite.yml中的“cookie”设置来完成这个任务。

acceptance.suite.yml

代码语言:javascript
复制
# 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:

代码语言:javascript
复制
<?php 
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure the homepage renders correctly');
$I->amOnPage('/'); 
$I->see('welcome');

但是,当我在调试模式下运行测试时,如下所示:

代码语言:javascript
复制
php codecept.phar run --debug

我可以看到没有请求饼干:

代码语言:javascript
复制
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

正确的语法是什么??

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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中提出了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34405890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档