diff options
Diffstat (limited to 'apps/user_status/tests/Unit')
6 files changed, 28 insertions, 44 deletions
diff --git a/apps/user_status/tests/Unit/CapabilitiesTest.php b/apps/user_status/tests/Unit/CapabilitiesTest.php index ef721eaa90b..f07892ff3fd 100644 --- a/apps/user_status/tests/Unit/CapabilitiesTest.php +++ b/apps/user_status/tests/Unit/CapabilitiesTest.php @@ -24,9 +24,7 @@ class CapabilitiesTest extends TestCase { $this->capabilities = new Capabilities($this->emojiHelper); } - /** - * @dataProvider getCapabilitiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getCapabilitiesDataProvider')] public function testGetCapabilities(bool $supportsEmojis): void { $this->emojiHelper->expects($this->once()) ->method('doesPlatformSupportEmoji') diff --git a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php index 45ee9c4fdba..e99290319ed 100644 --- a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php +++ b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php @@ -87,9 +87,7 @@ class UserStatusControllerTest extends TestCase { $this->controller->getStatus(); } - /** - * @dataProvider setStatusDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setStatusDataProvider')] public function testSetStatus( string $statusType, ?string $statusIcon, @@ -149,9 +147,7 @@ class UserStatusControllerTest extends TestCase { ]; } - /** - * @dataProvider setPredefinedMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setPredefinedMessageDataProvider')] public function testSetPredefinedMessage( string $messageId, ?int $clearAt, @@ -211,9 +207,7 @@ class UserStatusControllerTest extends TestCase { ]; } - /** - * @dataProvider setCustomMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setCustomMessageDataProvider')] public function testSetCustomMessage( ?string $statusIcon, string $message, diff --git a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php index c9bda492210..ea4480489c7 100644 --- a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php +++ b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php @@ -134,9 +134,7 @@ class UserStatusMapperTest extends TestCase { $this->mapper->insert($userStatus2); } - /** - * @dataProvider clearStatusesOlderThanDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('clearStatusesOlderThanDataProvider')] public function testClearStatusesOlderThan(string $status, bool $isUserDefined, int $timestamp, bool $expectsClean): void { $oldStatus = UserStatus::fromParams([ 'userId' => 'john.doe', @@ -233,9 +231,7 @@ class UserStatusMapperTest extends TestCase { ]; } - /** - * @dataProvider dataCreateBackupStatus - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCreateBackupStatus')] public function testCreateBackupStatus(bool $hasStatus, bool $hasBackup, bool $backupCreated): void { if ($hasStatus) { $userStatus1 = new UserStatus(); diff --git a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php index c94315a7a93..c03eed0089e 100644 --- a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php +++ b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php @@ -49,9 +49,7 @@ class UserLiveStatusListenerTest extends TestCase { ); } - /** - * @dataProvider handleEventWithCorrectEventDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('handleEventWithCorrectEventDataProvider')] public function testHandleWithCorrectEvent( string $userId, string $previousStatus, diff --git a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php index 091466637f0..78e4a18d9f1 100644 --- a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php +++ b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php @@ -26,7 +26,7 @@ class PredefinedStatusServiceTest extends TestCase { } public function testGetDefaultStatuses(): void { - $this->l10n->expects($this->exactly(7)) + $this->l10n->expects($this->exactly(8)) ->method('t') ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); @@ -53,6 +53,15 @@ class PredefinedStatusServiceTest extends TestCase { ], ], [ + 'id' => 'be-right-back', + 'icon' => '⏳', + 'message' => 'Be right back', + 'clearAt' => [ + 'type' => 'period', + 'time' => 900, + ], + ], + [ 'id' => 'remote-work', 'icon' => '🏡', 'message' => 'Working remotely', @@ -93,9 +102,7 @@ class PredefinedStatusServiceTest extends TestCase { ], $actual); } - /** - * @dataProvider getIconForIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getIconForIdDataProvider')] public function testGetIconForId(string $id, ?string $expectedIcon): void { $actual = $this->service->getIconForId($id); $this->assertEquals($expectedIcon, $actual); @@ -108,14 +115,13 @@ class PredefinedStatusServiceTest extends TestCase { ['sick-leave', '🤒'], ['vacationing', '🌴'], ['remote-work', '🏡'], + ['be-right-back', '⏳'], ['call', '💬'], ['unknown-id', null], ]; } - /** - * @dataProvider getTranslatedStatusForIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getTranslatedStatusForIdDataProvider')] public function testGetTranslatedStatusForId(string $id, ?string $expected): void { $this->l10n->method('t') ->willReturnArgument(0); @@ -131,14 +137,13 @@ class PredefinedStatusServiceTest extends TestCase { ['sick-leave', 'Out sick'], ['vacationing', 'Vacationing'], ['remote-work', 'Working remotely'], + ['be-right-back', 'Be right back'], ['call', 'In a call'], ['unknown-id', null], ]; } - /** - * @dataProvider isValidIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('isValidIdDataProvider')] public function testIsValidId(string $id, bool $expected): void { $actual = $this->service->isValidId($id); $this->assertEquals($expected, $actual); @@ -151,13 +156,14 @@ class PredefinedStatusServiceTest extends TestCase { ['sick-leave', true], ['vacationing', true], ['remote-work', true], + ['be-right-back', true], ['call', true], ['unknown-id', false], ]; } public function testGetDefaultStatusById(): void { - $this->l10n->expects($this->exactly(7)) + $this->l10n->expects($this->exactly(8)) ->method('t') ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); diff --git a/apps/user_status/tests/Unit/Service/StatusServiceTest.php b/apps/user_status/tests/Unit/Service/StatusServiceTest.php index 7aeb1d48448..7dfa5b0d064 100644 --- a/apps/user_status/tests/Unit/Service/StatusServiceTest.php +++ b/apps/user_status/tests/Unit/Service/StatusServiceTest.php @@ -221,9 +221,7 @@ class StatusServiceTest extends TestCase { $this->assertNull($status->getMessageId()); } - /** - * @dataProvider setStatusDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setStatusDataProvider')] public function testSetStatus( string $userId, string $status, @@ -344,9 +342,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider setPredefinedMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setPredefinedMessageDataProvider')] public function testSetPredefinedMessage( string $userId, string $messageId, @@ -433,9 +429,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider setCustomMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setCustomMessageDataProvider')] public function testSetCustomMessage( string $userId, ?string $statusIcon, @@ -799,9 +793,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider dataSetUserStatus - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetUserStatus')] public function testSetUserStatus(string $messageId, string $oldMessageId, bool $expectedUpdateShortcut): void { $previous = new UserStatus(); $previous->setId(1); |