为什么Codeception的PhpBrowser不遵循“重新加载”标题?

时间:2013-10-19 02:19:02

标签: php codeigniter ion-auth codeception

CodeIgniter的真实Ion Auth authentication library项目中发生了这种情况,但为了清楚起见,我已将其缩减为最简单的形式。

脚本:

我有一行脚本位于http://localhost/~captbaritone/redirect/index.php

<?php header("Refresh:0;url=https://google.com");¬

在我的浏览器中,它会重定向到Google.com。

测试:

为了测试它,我写了这个验收测试:

<?php
$I = new WebGuy($scenario);
$I->wantTo('Redirect to Google.com');
$I->amOnPage('/index.php');
$I->seeCurrentUrlEquals('https://www.google.com/');

我的acceptance.suite.yml看起来像这样:

class_name: WebGuy
modules:
    enabled:
        - PhpBrowser
        - WebHelper
    config:
        PhpBrowser:
            url: 'http://localhost/~captbaritone/redirect/'

结果:

Codeception PHP Testing Framework v1.7.1
Powered by PHPUnit 3.7.27 by Sebastian Bergmann.

Acceptance Tests (1) -----------------------------------------
Trying to redirect to google.com (RedirectCept.php)       Fail
---------------------------------------------------------------


Time: 460 ms, Memory: 9.75Mb

There was 1 failure:

---------
1) Failed to redirect to google.com in RedirectCept.php
Sorry, I couldn't see current url equals "https://www.google.com/":
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'https://www.google.com/'
+'/~captbaritone/redirect/index.php'

Scenario Steps:
2. I see current url equals "https://www.google.com/"
1. I am on page "/index.php"

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

我的问题:

显然,PhpBrowser不遵守重定向。将重定向更改为位置标头允许测试通过,但我不想(不能)更改我的应用程序以适应测试套件。

这是Codeception中的错误吗?在PhpBrowser? (我不清楚一个人从哪里开始,另一个人开始,或者PhpBrowser是否是一个单独的项目。)或者这可能是我不应该从无头浏览器中获得的功能?

我应该透露这是我第一次使用测试套件。

1 个答案:

答案 0 :(得分:1)

这在Codeception 2.0中修复:

https://github.com/Codeception/Codeception/issues/625#issuecomment-33281671

我建议您升级并重试。