diff options
Diffstat (limited to 'tests/lib/Activity/ManagerTest.php')
-rw-r--r-- | tests/lib/Activity/ManagerTest.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index 61eeee82c43..db0bedce359 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/tests/lib/Activity/ManagerTest.php @@ -9,6 +9,8 @@ namespace Test\Activity; use OCP\Activity\Exceptions\IncompleteActivityException; +use OCP\Activity\IConsumer; +use OCP\Activity\IEvent; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -74,7 +76,7 @@ class ManagerTest extends TestCase { self::invokePrivate($this->activityManager, 'getConsumers'); } - public function getUserFromTokenThrowInvalidTokenData() { + public static function getUserFromTokenThrowInvalidTokenData(): array { return [ [null, []], ['', []], @@ -86,11 +88,11 @@ class ManagerTest extends TestCase { } /** - * @dataProvider getUserFromTokenThrowInvalidTokenData * * @param string $token * @param array $users */ + #[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenThrowInvalidTokenData')] public function testGetUserFromTokenThrowInvalidToken($token, $users): void { $this->expectException(\UnexpectedValueException::class); @@ -98,7 +100,7 @@ class ManagerTest extends TestCase { self::invokePrivate($this->activityManager, 'getUserFromToken'); } - public function getUserFromTokenData() { + public static function getUserFromTokenData(): array { return [ [null, '123456789012345678901234567890', 'user1'], ['user2', null, 'user2'], @@ -107,12 +109,12 @@ class ManagerTest extends TestCase { } /** - * @dataProvider getUserFromTokenData * * @param string $userLoggedIn * @param string $token * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenData')] public function testGetUserFromToken($userLoggedIn, $token, $expected): void { if ($userLoggedIn !== null) { $this->mockUserSession($userLoggedIn); @@ -190,7 +192,7 @@ class ManagerTest extends TestCase { $this->activityManager->publish($event); } - public function dataPublish() { + public static function dataPublish(): array { return [ [null, ''], ['test_author', 'test_author'], @@ -198,10 +200,10 @@ class ManagerTest extends TestCase { } /** - * @dataProvider dataPublish * @param string|null $author * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublish')] public function testPublish($author, $expected): void { if ($author !== null) { $authorObject = $this->getMockBuilder(IUser::class) @@ -228,7 +230,7 @@ class ManagerTest extends TestCase { $consumer->expects($this->once()) ->method('receive') ->with($event) - ->willReturnCallback(function (\OCP\Activity\IEvent $event) use ($expected) { + ->willReturnCallback(function (IEvent $event) use ($expected): void { $this->assertLessThanOrEqual(time() + 2, $event->getTimestamp(), 'Timestamp not set correctly'); $this->assertGreaterThanOrEqual(time() - 2, $event->getTimestamp(), 'Timestamp not set correctly'); $this->assertSame($expected, $event->getAuthor(), 'Author name not set correctly'); @@ -258,7 +260,7 @@ class ManagerTest extends TestCase { ->getMock(); $consumer->expects($this->once()) ->method('receive') - ->willReturnCallback(function (\OCP\Activity\IEvent $event) { + ->willReturnCallback(function (IEvent $event): void { $this->assertSame('test_app', $event->getApp(), 'App not set correctly'); $this->assertSame('test_type', $event->getType(), 'Type not set correctly'); $this->assertSame('test_affected', $event->getAffectedUser(), 'Affected user not set correctly'); @@ -281,7 +283,7 @@ class ManagerTest extends TestCase { } } -class NoOpConsumer implements \OCP\Activity\IConsumer { - public function receive(\OCP\Activity\IEvent $event) { +class NoOpConsumer implements IConsumer { + public function receive(IEvent $event) { } } |