Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Commit 68b5785

Browse files
committed
Fix mocking issue in PHPUnit 9.2
1 parent 58ce582 commit 68b5785

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Tests/Security/Http/Authentication/DefaultAuthenticationRequiredHandlerTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ protected function setUp(): void
4444
{
4545
$this->httpUtils = $this->createMock(HttpUtils::class);
4646
$this->request = $this->createMock(Request::class);
47-
4847
$this->authFormRedirectResponse = $this->createMock(RedirectResponse::class);
49-
$this->httpUtils
50-
->expects($this->any())
51-
->method('createRedirectResponse')
52-
->with($this->request, self::FORM_PATH)
53-
->willReturn($this->authFormRedirectResponse);
5448

5549
$options = [
5650
'auth_form_path' => self::FORM_PATH,
@@ -65,6 +59,15 @@ protected function setUp(): void
6559
);
6660
}
6761

62+
private function stubRedirectResponse(): void
63+
{
64+
$this->httpUtils
65+
->expects($this->any())
66+
->method('createRedirectResponse')
67+
->with($this->request, self::FORM_PATH)
68+
->willReturn($this->authFormRedirectResponse);
69+
}
70+
6871
private function stubCurrentPath(string $currentPath): void
6972
{
7073
$this->request
@@ -164,6 +167,7 @@ public function onAuthenticationRequired_isNotCheckPath_saveRedirectUrl(): void
164167
{
165168
$token = $this->createMock(TokenInterface::class);
166169
$this->stubCurrentPath('/somePath');
170+
$this->stubRedirectResponse();
167171

168172
$this->assertSaveTargetUrl('/somePath');
169173
$this->handler->onAuthenticationRequired($this->request, $token);
@@ -176,6 +180,7 @@ public function onAuthenticationRequired_isCheckPath_notSaveRedirectUrl(): void
176180
{
177181
$token = $this->createMock(TokenInterface::class);
178182
$this->stubCurrentPathIsCheckPath();
183+
$this->stubRedirectResponse();
179184

180185
$this->assertNotSaveTargetUrl();
181186
$this->handler->onAuthenticationRequired($this->request, $token);

0 commit comments

Comments
 (0)