Skip to content

Commit 165d363

Browse files
committed
test fix
1 parent 5f9bf2d commit 165d363

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Domain/Identity/Service/SessionManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PhpList\Core\Domain\Identity\Service;
66

77
use PhpList\Core\Domain\Common\I18n\Messages;
8-
use PhpList\Core\Domain\Common\I18n\TranslatorInterface;
8+
use Symfony\Contracts\Translation\TranslatorInterface;
99
use PhpList\Core\Domain\Configuration\Service\Manager\EventLogManager;
1010
use PhpList\Core\Domain\Identity\Model\AdministratorToken;
1111
use PhpList\Core\Domain\Identity\Repository\AdministratorRepository;
@@ -35,16 +35,16 @@ public function createSession(string $loginName, string $password): Administrato
3535
{
3636
$administrator = $this->administratorRepository->findOneByLoginCredentials($loginName, $password);
3737
if ($administrator === null) {
38-
$entry = $this->translator->translate(Messages::AUTH_LOGIN_FAILED, ['login' => $loginName]);
38+
$entry = $this->translator->trans(Messages::AUTH_LOGIN_FAILED, ['login' => $loginName]);
3939
$this->eventLogManager->log('login', $entry);
40-
$message = $this->translator->translate(Messages::AUTH_NOT_AUTHORIZED);
40+
$message = $this->translator->trans(Messages::AUTH_NOT_AUTHORIZED);
4141
throw new UnauthorizedHttpException('', $message, null, 1500567098);
4242
}
4343

4444
if ($administrator->isDisabled()) {
45-
$entry = $this->translator->translate(Messages::AUTH_LOGIN_DISABLED, ['login' => $loginName]);
45+
$entry = $this->translator->trans(Messages::AUTH_LOGIN_DISABLED, ['login' => $loginName]);
4646
$this->eventLogManager->log('login', $entry);
47-
$message = $this->translator->translate(Messages::AUTH_NOT_AUTHORIZED);
47+
$message = $this->translator->trans(Messages::AUTH_NOT_AUTHORIZED);
4848
throw new UnauthorizedHttpException('', $message, null, 1500567099);
4949
}
5050

tests/Unit/Domain/Identity/Service/SessionManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace PhpList\Core\Tests\Unit\Domain\Identity\Service;
66

77
use PhpList\Core\Domain\Common\I18n\Messages;
8-
use PhpList\Core\Domain\Common\I18n\TranslatorInterface;
98
use PhpList\Core\Domain\Configuration\Service\Manager\EventLogManager;
109
use PhpList\Core\Domain\Identity\Model\AdministratorToken;
1110
use PhpList\Core\Domain\Identity\Repository\AdministratorRepository;
1211
use PhpList\Core\Domain\Identity\Repository\AdministratorTokenRepository;
1312
use PhpList\Core\Domain\Identity\Service\SessionManager;
1413
use PHPUnit\Framework\TestCase;
1514
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
15+
use Symfony\Contracts\Translation\TranslatorInterface;
1616

1717
class SessionManagerTest extends TestCase
1818
{
@@ -34,7 +34,7 @@ public function testCreateSessionWithInvalidCredentialsThrowsExceptionAndLogs():
3434

3535
$translator = $this->createMock(TranslatorInterface::class);
3636
$translator->expects(self::exactly(2))
37-
->method('translate')
37+
->method('trans')
3838
->withConsecutive(
3939
[Messages::AUTH_LOGIN_FAILED, ['login' => 'admin']],
4040
[Messages::AUTH_NOT_AUTHORIZED, []]

0 commit comments

Comments
 (0)