Skip to content

Commit 8f59cac

Browse files
committed
tests bug fix
Signed-off-by: MarioRadu <[email protected]>
1 parent d828225 commit 8f59cac

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

test/Unit/Admin/Handler/Account/PostAccountLoginHandlerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testInvalidLoginFormDataProvidedWillReturnRedirectResponse(): vo
9696

9797
$this
9898
->messenger
99-
->expects($this->once())
99+
->expects($this->atLeastOnce())
100100
->method('addError');
101101

102102
$handler = new PostAccountLoginHandler(
@@ -131,8 +131,8 @@ public function testInvalidPasswordProvidedWillReturnRedirectResponse(): void
131131
$this->authenticationAdapter->method('setCredential')->willReturn($this->authenticationAdapter);
132132
$this->authenticationService->method('getAdapter')->willReturn($this->authenticationAdapter);
133133

134-
$this->messenger->expects($this->once())->method('addError');
135-
$this->adminService->expects($this->once())->method('logAdminVisit');
134+
$this->messenger->expects($this->atLeastOnce())->method('addError');
135+
$this->adminService->expects($this->atLeastOnce())->method('logAdminVisit');
136136

137137
$handler = new PostAccountLoginHandler(
138138
$this->adminService,
@@ -167,13 +167,13 @@ public function testAdminInactiveWillReturnRedirectResponse(): void
167167

168168
$this
169169
->messenger
170-
->expects($this->once())
170+
->expects($this->atLeastOnce())
171171
->method('addError')
172172
->with(Message::ADMIN_INACTIVE);
173173

174174
$this
175175
->authenticationService
176-
->expects($this->once())
176+
->expects($this->atLeastOnce())
177177
->method('clearIdentity');
178178

179179
$handler = new PostAccountLoginHandler(
@@ -201,7 +201,7 @@ public function testAdminLoginThrowsExceptionWillReturnRedirectResponse(): void
201201

202202
$this
203203
->messenger
204-
->expects($this->once())
204+
->expects($this->atLeastOnce())
205205
->method('addError')
206206
->with(Message::AN_ERROR_OCCURRED);
207207

@@ -237,8 +237,8 @@ public function testAdminLoginSuccessfulWillReturnRedirectResponse(): void
237237
$this->authenticationAdapter->method('setCredential')->willReturn($this->authenticationAdapter);
238238
$this->authenticationService->method('getAdapter')->willReturn($this->authenticationAdapter);
239239

240-
$this->adminService->expects($this->once())->method('logAdminVisit');
241-
$this->storage->expects($this->once())->method('write')->with($this->identity);
240+
$this->adminService->expects($this->atLeastOnce())->method('logAdminVisit');
241+
$this->storage->expects($this->atLeastOnce())->method('write')->with($this->identity);
242242

243243
$handler = new PostAccountLoginHandler(
244244
$this->adminService,

test/Unit/Admin/Handler/Admin/GetAdminListHandlerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function testListAdminWillReturnHtmlResponse(): void
3131
$authenticationService = $this->createMock(AuthenticationServiceInterface::class);
3232
$form = $this->createMock(AdminForm::class);
3333
$adminRepository = $this->createMock(AdminRepository::class);
34+
$request = $this->createMock(ServerRequestInterface::class);
3435

36+
$request->method('getQueryParams')->willReturn([]);
3537
$adminRepository->method('findOneBy')->willReturn($this->createMock(Admin::class));
3638
$adminService->method('getAdmins')->willReturn([
3739
'rows' => [],
@@ -55,7 +57,7 @@ public function testListAdminWillReturnHtmlResponse(): void
5557
$form,
5658
);
5759

58-
$response = $handler->handle($this->createMock(ServerRequestInterface::class));
60+
$response = $handler->handle($request);
5961

6062
$this->assertSame($response->getHeader('content-type')[0], 'text/html; charset=utf-8');
6163
$this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());

0 commit comments

Comments
 (0)