2424use PHPUnit \Framework \MockObject \Exception as MockObjectException ;
2525use PHPUnit \Framework \MockObject \MockObject ;
2626use Psr \Http \Message \ServerRequestInterface ;
27+ use Psr \Http \Message \UriInterface ;
2728
2829class PostAccountLoginHandlerTest extends UnitTest
2930{
@@ -95,7 +96,7 @@ public function testInvalidLoginFormDataProvidedWillReturnRedirectResponse(): vo
9596
9697 $ this
9798 ->messenger
98- ->expects ($ this ->exactly ( 1 ))
99+ ->expects ($ this ->once ( ))
99100 ->method ('addError ' );
100101
101102 $ handler = new PostAccountLoginHandler (
@@ -130,8 +131,8 @@ public function testInvalidPasswordProvidedWillReturnRedirectResponse(): void
130131 $ this ->authenticationAdapter ->method ('setCredential ' )->willReturn ($ this ->authenticationAdapter );
131132 $ this ->authenticationService ->method ('getAdapter ' )->willReturn ($ this ->authenticationAdapter );
132133
133- $ this ->messenger ->expects ($ this ->exactly ( 1 ))->method ('addError ' );
134- $ this ->adminService ->expects ($ this ->exactly ( 1 ))->method ('logAdminVisit ' );
134+ $ this ->messenger ->expects ($ this ->once ( ))->method ('addError ' );
135+ $ this ->adminService ->expects ($ this ->once ( ))->method ('logAdminVisit ' );
135136
136137 $ handler = new PostAccountLoginHandler (
137138 $ this ->adminService ,
@@ -166,13 +167,13 @@ public function testAdminInactiveWillReturnRedirectResponse(): void
166167
167168 $ this
168169 ->messenger
169- ->expects ($ this ->exactly ( 1 ))
170+ ->expects ($ this ->once ( ))
170171 ->method ('addError ' )
171172 ->with (Message::ADMIN_INACTIVE );
172173
173174 $ this
174175 ->authenticationService
175- ->expects ($ this ->exactly ( 1 ))
176+ ->expects ($ this ->once ( ))
176177 ->method ('clearIdentity ' );
177178
178179 $ handler = new PostAccountLoginHandler (
@@ -190,13 +191,17 @@ public function testAdminInactiveWillReturnRedirectResponse(): void
190191 $ this ->assertSame (StatusCodeInterface::STATUS_SEE_OTHER , $ response ->getStatusCode ());
191192 }
192193
194+ /**
195+ * @throws MockObjectException
196+ */
193197 public function testAdminLoginThrowsExceptionWillReturnRedirectResponse (): void
194198 {
199+ $ this ->request ->method ('getUri ' )->willReturn ($ this ->createMock (UriInterface::class));
195200 $ this ->throwException (new Exception ());
196201
197202 $ this
198203 ->messenger
199- ->expects ($ this ->exactly ( 1 ))
204+ ->expects ($ this ->once ( ))
200205 ->method ('addError ' )
201206 ->with (Message::AN_ERROR_OCCURRED );
202207
@@ -232,8 +237,8 @@ public function testAdminLoginSuccessfulWillReturnRedirectResponse(): void
232237 $ this ->authenticationAdapter ->method ('setCredential ' )->willReturn ($ this ->authenticationAdapter );
233238 $ this ->authenticationService ->method ('getAdapter ' )->willReturn ($ this ->authenticationAdapter );
234239
235- $ this ->adminService ->expects ($ this ->exactly ( 1 ))->method ('logAdminVisit ' );
236- $ this ->storage ->expects ($ this ->exactly ( 1 ))->method ('write ' )->with ($ this ->identity );
240+ $ this ->adminService ->expects ($ this ->once ( ))->method ('logAdminVisit ' );
241+ $ this ->storage ->expects ($ this ->once ( ))->method ('write ' )->with ($ this ->identity );
237242
238243 $ handler = new PostAccountLoginHandler (
239244 $ this ->adminService ,
0 commit comments