提交带有Codeception的表单时无效的cookie


Invalid cookie on submitting a form with Codeception

我正在尝试用Codeception(验收测试)测试我的项目。一切都很顺利,直到我不得不提交一个带有Paypal按钮的表单。
调试时显示

I submit form "form:nth-child(3)",
[Uri] https://www.sandbox.paypal.com/cgi-bin/webscr
[Method] POST
[Parameters] {"cmd":"_s-xclick","hosted_button_id":"BUTTONID"}
ERROR

然后是

[RuntimeException] Invalid cookie: The cookie value must not be empty

我不设置任何饼干在测试期间。也不知道为什么会出现这个错误。

这是我的accept .suite.yml

class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser:
            url: http://test.mysite.com
        - 'Helper'Acceptance

这是我的SubscriptionCest.php:

<?php
use 'AcceptanceTester;
class SubscriptionCest
{
    public function _before(AcceptanceTester $I)
    {
    }
    public function _after(AcceptanceTester $I)
    {
    }
    // Main function
    public function run(AcceptanceTester $I)
    {
        $I->am("New user");
        $I->wantTo("purchase a membership");
        $I->amOnPage("/subscription");
        $I->submitForm("form:nth-child(3)", []);
    }
}

这是paypal表单的HTML:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BUTTONID">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

为什么会出现这个错误?如何解决这个问题?谢谢。

原来是一个bug,现在已经修复了。版本2.1应该让它像魔法一样工作。欲了解更多信息,请访问https://github.com/Codeception/Codeception/issues/2234