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.
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.