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 ;
5534
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 ;
46+
47+ #[\Override]
5648 protected function setUp (): void {
5749 parent ::setUp ();
5850
5951 $ this ->mapper = $ this ->createMock (PublicKeyTokenMapper::class);
60- $ this ->hasher = Server::get (IHasher::class);
61- $ this ->crypto = Server::get (ICrypto::class);
6252 $ this ->config = $ this ->createMock (IConfig::class);
6353 $ this ->config ->method ('getSystemValue ' )
6454 ->willReturnMap ([
@@ -75,6 +65,9 @@ protected function setUp(): void {
7565 $ this ->timeFactory ->method ('getTime ' )
7666 ->willReturn ($ this ->time );
7767 $ this ->cacheFactory = $ this ->createMock (ICacheFactory::class);
68+
69+ $ this ->hasher = Server::get (IHasher::class);
70+ $ this ->crypto = Server::get (ICrypto::class);
7871 $ this ->eventDispatcher = Server::get (IEventDispatcher::class);
7972
8073 $ this ->tokenProvider = new PublicKeyTokenProvider (
@@ -236,7 +229,6 @@ public function testGetPassword(): void {
236229 $ this ->assertSame ($ password , $ this ->tokenProvider ->getPassword ($ actual , $ token ));
237230 }
238231
239-
240232 public function testGetPasswordPasswordLessToken (): void {
241233 $ this ->expectException (PasswordlessTokenException::class);
242234
@@ -247,7 +239,6 @@ public function testGetPasswordPasswordLessToken(): void {
247239 $ this ->tokenProvider ->getPassword ($ tk , $ token );
248240 }
249241
250-
251242 public function testGetPasswordInvalidToken (): void {
252243 $ this ->expectException (InvalidTokenException::class);
253244
@@ -292,13 +283,11 @@ public function testSetPassword(): void {
292283 return $ newpass === $ this ->tokenProvider ->getPassword ($ token , 'tokentokentokentokentoken ' );
293284 }));
294285
295-
296286 $ this ->tokenProvider ->setPassword ($ actual , $ token , $ newpass );
297287
298288 $ this ->assertSame ($ newpass , $ this ->tokenProvider ->getPassword ($ actual , 'tokentokentokentokentoken ' ));
299289 }
300290
301-
302291 public function testSetPasswordInvalidToken (): void {
303292 $ this ->expectException (InvalidTokenException::class);
304293
@@ -451,6 +440,7 @@ public function testRenewSessionTokenWithPassword(): void {
451440
452441 public function testGetToken (): void {
453442 $ token = new PublicKeyToken ();
443+ $ token ->setType (IToken::TEMPORARY_TOKEN );
454444
455445 $ this ->config ->method ('getSystemValue ' )
456446 ->with ('secret ' )
0 commit comments