diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php
index 7d80e37..a6d7896 100644
--- a/src/Codeception/Lib/InnerBrowser.php
+++ b/src/Codeception/Lib/InnerBrowser.php
@@ -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 = [];
}
/**
diff --git a/tests/data/app/view/index.php b/tests/data/app/view/index.php
index 3890759..f797d32 100755
--- a/tests/data/app/view/index.php
+++ b/tests/data/app/view/index.php
@@ -30,6 +30,7 @@
Link Text
+Test redirect
A wise man said: "debug!"
diff --git a/tests/unit/Codeception/Module/TestsForWeb.php b/tests/unit/Codeception/Module/TestsForWeb.php
index 10a3868..69a73cb 100644
--- a/tests/unit/Codeception/Module/TestsForWeb.php
+++ b/tests/unit/Codeception/Module/TestsForWeb.php
@@ -8,6 +8,7 @@
use Codeception\Test\Unit;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\ExpectationFailedException;
+use Symfony\Component\BrowserKit\Response;
/**
* Author: davert
@@ -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');
+ }
}