Why doesn't Codeception's PhpBrowser follow a “Reload” header?

最后都变了- 提交于 2020-01-14 10:06:45

问题


This is happening to me in a real CodeIgniter project in the Ion Auth authentication library, but for the sake of clarity, I have reduced it to it's simplest form.

The script:

I have this one line script located at http://localhost/~captbaritone/redirect/index.php:

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

In my browser, it redirects to Google.com.

The Test:

To test it I wrote this acceptance test:

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

My acceptance.suite.yml looks like this:

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

The results:

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.

My Question:

Clearly the PhpBrowser is not obeying the redirect. Changing the redirect to a location header, allows the test to pass, but I don't want to (can't) change my application to fit the test suite.

Is this a bug in Codeception? In PhpBrowser? (I'm not really clear on where one starts and the other begins, or if PhpBrowser is even a separate project.) Or maybe this is a functionality I shouldn't expect from a headless browser?

I should disclose that this is my first time working with a test suite.


回答1:


This is fixed in a Codeception 2.0:

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

I would suggest you upgrade and try again.



来源:https://stackoverflow.com/questions/19461630/why-doesnt-codeceptions-phpbrowser-follow-a-reload-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!