5

这发生在Ion Auth authentication library中的一个真实CodeIgniter项目中,但为了清楚起见,我将其简化为最简单的形式。

剧本:

我有这个单行脚本位于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 是否甚至是一个单独的项目。)或者也许这是我不应该从无头浏览器获得的功能?

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

4

1 回答 1

1

这在 Codeception 2.0 中得到了修复:

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

我建议您升级并重试。

于 2015-04-15T18:00:02.153 回答