Why does the Codeception PhpBrowser not match the Refresh header?

This happens to me in a real CodeIgniter project in the Ion Auth authentication library , but for clarity, I have reduced it to its simplest form.

script:

I have one line of 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.

Test:

To test this, 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 as follows:

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

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 is:

Obviously, PhpBrowser is not subject to redirection. Changing the redirection to the location header allows me to pass the test, but I do not want (cannot) change my application according to the set of tests.

Is this a bug in Codeception? In phpbrowser? (I donโ€™t quite understand where to start, and another starts, or if PhpBrowser is even a separate project.) Or maybe this is a functionality that I should not expect from a headless browser?

I must report that this is my first experience with a test suite.

+5
source share
1 answer

This is fixed in Codeception 2.0:

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

I suggest you update and try again.

+1
source

Source: https://habr.com/ru/post/956294/


All Articles