Skip to content

Commit b531022

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

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Admin/src/Handler/Account/PostAccountLoginHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Admin\Admin\Handler\Account;
66

77
use Admin\Admin\Adapter\AuthenticationAdapter;
8+
use Admin\Admin\Entity\AdminIdentity;
89
use Admin\Admin\Enum\AdminStatusEnum;
910
use Admin\Admin\Enum\SuccessFailureEnum;
1011
use Admin\Admin\Form\LoginForm;
@@ -90,8 +91,9 @@ public function handle(ServerRequestInterface $request): ResponseInterface
9091

9192
return new RedirectResponse($request->getUri(), StatusCodeInterface::STATUS_SEE_OTHER);
9293
} else {
94+
/** @var AdminIdentity $identity */
9395
$identity = $authResult->getIdentity();
94-
if ($identity->getStatus() === AdminStatusEnum::Inactive) {
96+
if ($identity->getStatus()->value === AdminStatusEnum::Inactive->value) {
9597
$this->authenticationService->clearIdentity();
9698
$this->messenger->addError(Message::ADMIN_INACTIVE);
9799
$this->messenger->addData('shouldRebind', true);

test/Unit/Admin/Handler/Admin/GetAdminLoginListHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Admin\Admin\Entity\Admin;
88
use Admin\Admin\Entity\AdminIdentity;
9-
use Admin\Admin\Form\AdminForm;
109
use Admin\Admin\Handler\Admin\GetAdminLoginListHandler;
1110
use Admin\Admin\Repository\AdminRepository;
1211
use Admin\Admin\Service\AdminServiceInterface;
@@ -27,9 +26,10 @@ public function testListAdminWillReturnHtmlResponse(): void
2726
$adminService = $this->createMock(AdminServiceInterface::class);
2827
$template = $this->createMock(TemplateRendererInterface::class);
2928
$authenticationService = $this->createMock(AuthenticationServiceInterface::class);
30-
$form = $this->createMock(AdminForm::class);
3129
$adminRepository = $this->createMock(AdminRepository::class);
30+
$request = $this->createMock(ServerRequestInterface::class);
3231

32+
$request->method('getQueryParams')->willReturn([]);
3333
$adminRepository->method('findOneBy')->willReturn($this->createMock(Admin::class));
3434
$adminService->method('getAdminLogins')->willReturn([
3535
'rows' => [],
@@ -51,7 +51,7 @@ public function testListAdminWillReturnHtmlResponse(): void
5151
$authenticationService,
5252
);
5353

54-
$response = $handler->handle($this->createMock(ServerRequestInterface::class));
54+
$response = $handler->handle($request);
5555

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

0 commit comments

Comments
 (0)