Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,9 @@ public function startFollowingRedirects(): void
*/
public function followRedirect(): void
{
$this->client->followRedirect();
$this->crawler = $this->client->followRedirect();
$this->baseUrl = $this->retrieveBaseUrl();
$this->forms = [];
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/data/app/view/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</div>

<a href="/info" title="Link Title">Link Text</a>
<a href="/redirect">Test redirect</a>


A wise man said: "debug!"
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/Codeception/Module/TestsForWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Codeception\Test\Unit;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Component\BrowserKit\Response;

/**
* Author: davert
Expand Down Expand Up @@ -1866,4 +1867,26 @@ public function testUncheckHidden()
$this->assertFalse(isset($form['butter']));

}

public function testManualRedirect()
{
$this->module->amOnPage('/info');
$this->module->see('Information', 'h1');

$this->module->stopFollowingRedirects();
$this->module->amOnPage('/');
$this->module->seeResponseCodeIsBetween(200, 299);
$this->module->see('Welcome to test app!', 'h1');

// Workaround https://github.com/Codeception/util-universalframework/issues/3
$this->module->client->mockResponse(new Response('', 301, [
'Location' => '/info',
]));

$this->module->click('Test redirect');
$this->module->seeResponseCodeIs(301);
$this->module->followRedirect();
$this->module->seeCurrentUrlEquals('/info');
$this->module->see('Information', 'h1');
}
}