aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/Token/ManagerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Authentication/Token/ManagerTest.php')
-rw-r--r--tests/lib/Authentication/Token/ManagerTest.php41
1 files changed, 31 insertions, 10 deletions
diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php
index 4fde9817d09..0f95d1d2f2c 100644
--- a/tests/lib/Authentication/Token/ManagerTest.php
+++ b/tests/lib/Authentication/Token/ManagerTest.php
@@ -128,10 +128,10 @@ class ManagerTest extends TestCase {
$this->assertSame(121, mb_strlen($actual->getName()));
}
- public function tokenData(): array {
+ public static function tokenData(): array {
return [
[new PublicKeyToken()],
- [$this->createMock(IToken::class)],
+ [IToken::class],
];
}
@@ -160,7 +160,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testUpdateToken(IToken $token): void {
+ public function testUpdateToken(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'updateToken');
$this->setException($token);
@@ -171,7 +175,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testUpdateTokenActivity(IToken $token): void {
+ public function testUpdateTokenActivity(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'updateTokenActivity');
$this->setException($token);
@@ -182,7 +190,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testGetPassword(IToken $token): void {
+ public function testGetPassword(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'getPassword', 'password');
$this->setException($token);
@@ -195,7 +207,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testSetPassword(IToken $token): void {
+ public function testSetPassword(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'setPassword');
$this->setException($token);
@@ -358,13 +374,18 @@ class ManagerTest extends TestCase {
->method('getTokenByUser')
->with('theUser')
->willReturn([$t1, $t2]);
+
+ $calls = [
+ ['theUser', 123],
+ ['theUser', 456],
+ ];
$this->publicKeyTokenProvider
->expects($this->exactly(2))
->method('invalidateTokenById')
- ->withConsecutive(
- ['theUser', 123],
- ['theUser', 456],
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->manager->invalidateTokensOfUser('theUser', null);
}