1- < ?php
1+ et ?php
22
33declare(strict_types=1);
44
3030use Test\TestCase;
3131
3232class PublicKeyTokenProviderTest extends TestCase {
33- /** @var PublicKeyTokenProvider|\PHPUnit\Framework\MockObject\MockObject */
34- private $ tokenProvider ;
35- /** @var PublicKeyTokenMapper|\PHPUnit\Framework\MockObject\MockObject */
36- private $ mapper ;
37- /** @var IHasher|\PHPUnit\Framework\MockObject\MockObject */
38- private $ hasher ;
39- /** @var ICrypto */
40- private $ crypto ;
41- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
42- private $ config ;
43- /** @var IDBConnection|MockObject */
44- private IDBConnection $ db ;
45- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
46- private $ logger ;
47- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
48- private $ timeFactory ;
49- /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
50- private $ cacheFactory ;
51- /** @var int */
52- private $ time ;
53- /** @var IEventDispatcher */
54- private $ eventDispatcher ;
33+ private PublicKeyTokenProvider $tokenProvider;
34+
35+ private PublicKeyTokenMapper&MockObject $mapper;
36+ private IConfig&MockObject $config;
37+ private IDBConnection&MockObject $db;
38+ private LoggerInterface&MockObject $logger;
39+ private ITimeFactory&MockObject $timeFactory;
40+ private ICacheFactory&MockObject $cacheFactory;
41+
42+ private int $time;
43+ private IHasher $hasher;
44+ private ICrypto $crypto;
45+ private IEventDispatcher $eventDispatcher;
5546
5647 #[\Override]
5748 protected function setUp(): void {
5849 parent::setUp();
5950
6051 $this->mapper = $this->createMock(PublicKeyTokenMapper::class);
61- $ this ->hasher = Server::get (IHasher::class);
62- $ this ->crypto = Server::get (ICrypto::class);
6352 $this->config = $this->createMock(IConfig::class);
6453 $this->config->method('getSystemValue')
6554 ->willReturnMap([
@@ -76,6 +65,9 @@ protected function setUp(): void {
7665 $this->timeFactory->method('getTime')
7766 ->willReturn($this->time);
7867 $this->cacheFactory = $this->createMock(ICacheFactory::class);
68+
69+ $this->hasher = Server::get(IHasher::class);
70+ $this->crypto = Server::get(ICrypto::class);
7971 $this->eventDispatcher = Server::get(IEventDispatcher::class);
8072
8173 $this->tokenProvider = new PublicKeyTokenProvider(
@@ -237,7 +229,6 @@ public function testGetPassword(): void {
237229 $this->assertSame($password, $this->tokenProvider->getPassword($actual, $token));
238230 }
239231
240-
241232 public function testGetPasswordPasswordLessToken(): void {
242233 $this->expectException(PasswordlessTokenException::class);
243234
@@ -248,7 +239,6 @@ public function testGetPasswordPasswordLessToken(): void {
248239 $this->tokenProvider->getPassword($tk, $token);
249240 }
250241
251-
252242 public function testGetPasswordInvalidToken(): void {
253243 $this->expectException(InvalidTokenException::class);
254244
@@ -293,13 +283,11 @@ public function testSetPassword(): void {
293283 return $newpass === $this->tokenProvider->getPassword($token, 'tokentokentokentokentoken');
294284 }));
295285
296-
297286 $this->tokenProvider->setPassword($actual, $token, $newpass);
298287
299288 $this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'tokentokentokentokentoken'));
300289 }
301290
302-
303291 public function testSetPasswordInvalidToken(): void {
304292 $this->expectException(InvalidTokenException::class);
305293
@@ -452,6 +440,7 @@ public function testRenewSessionTokenWithPassword(): void {
452440
453441 public function testGetToken(): void {
454442 $token = new PublicKeyToken();
443+ $token->setType(IToken::TEMPORARY_TOKEN);
455444
456445 $this->config->method('getSystemValue')
457446 ->with('secret')
0 commit comments