Skip to content

Commit d828225

Browse files
committed
tests bug fix
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
1 parent bd56d03 commit d828225

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testInvalidConfirmPasswordProvidedWillReturnRedirectResponse():
112112

113113
$this
114114
->messenger
115-
->expects($this->exactly(1))
115+
->expects($this->once())
116116
->method('addError')
117117
->with(Message::CURRENT_PASSWORD_INCORRECT);
118118

@@ -147,13 +147,13 @@ public function testThrowIdentityExceptionWillReturnRedirectResponse(): void
147147

148148
$this
149149
->messenger
150-
->expects($this->exactly(1))
150+
->expects($this->once())
151151
->method('addError')
152152
->with((new IdentityException())->getMessage());
153153

154154
$this
155155
->adminService
156-
->expects($this->exactly(1))
156+
->expects($this->once())
157157
->method('updateAdmin');
158158

159159
$handler = new PostAccountChangePasswordHandler(
@@ -187,7 +187,7 @@ public function testThrowExceptionWillReturnRedirectResponse(): void
187187

188188
$this
189189
->messenger
190-
->expects($this->exactly(1))
190+
->expects($this->once())
191191
->method('addError')
192192
->with(Message::AN_ERROR_OCCURRED);
193193

@@ -221,7 +221,7 @@ public function testValidFormDataWillReturnRedirectResponse(): void
221221

222222
$this
223223
->messenger
224-
->expects($this->exactly(1))
224+
->expects($this->once())
225225
->method('addSuccess')
226226
->with(Message::ACCOUNT_UPDATE_SUCCESSFULLY);
227227

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testThrowIdentityExceptionWillReturnRedirectResponse(): void
106106

107107
$this
108108
->messenger
109-
->expects($this->exactly(1))
109+
->expects($this->once())
110110
->method('addError')
111111
->with(Message::AN_ERROR_OCCURRED);
112112

@@ -141,7 +141,7 @@ public function testThrowExceptionWillReturnRedirectResponse(): void
141141

142142
$this
143143
->messenger
144-
->expects($this->exactly(1))
144+
->expects($this->once())
145145
->method('addError')
146146
->with(Message::AN_ERROR_OCCURRED);
147147

@@ -175,7 +175,7 @@ public function testValidFormDataWillReturnRedirectResponse(): void
175175

176176
$this
177177
->messenger
178-
->expects($this->exactly(1))
178+
->expects($this->once())
179179
->method('addSuccess')
180180
->with(Message::ACCOUNT_UPDATE_SUCCESSFULLY);
181181

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use PHPUnit\Framework\MockObject\Exception as MockObjectException;
2525
use PHPUnit\Framework\MockObject\MockObject;
2626
use Psr\Http\Message\ServerRequestInterface;
27+
use Psr\Http\Message\UriInterface;
2728

2829
class 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

Comments
 (0)