aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php')
-rw-r--r--apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php61
1 files changed, 23 insertions, 38 deletions
diff --git a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php
index 12b34ed0b4d..78e4a18d9f1 100644
--- a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php
+++ b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php
@@ -10,15 +10,12 @@ namespace OCA\UserStatus\Tests\Service;
use OCA\UserStatus\Service\PredefinedStatusService;
use OCP\IL10N;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class PredefinedStatusServiceTest extends TestCase {
-
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
- protected $l10n;
-
- /** @var PredefinedStatusService */
- protected $service;
+ protected IL10N&MockObject $l10n;
+ protected PredefinedStatusService $service;
protected function setUp(): void {
parent::setUp();
@@ -29,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);
@@ -56,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',
@@ -96,38 +102,26 @@ class PredefinedStatusServiceTest extends TestCase {
], $actual);
}
- /**
- * @param string $id
- * @param string|null $expectedIcon
- *
- * @dataProvider getIconForIdDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('getIconForIdDataProvider')]
public function testGetIconForId(string $id, ?string $expectedIcon): void {
$actual = $this->service->getIconForId($id);
$this->assertEquals($expectedIcon, $actual);
}
- /**
- * @return array
- */
- public function getIconForIdDataProvider(): array {
+ public static function getIconForIdDataProvider(): array {
return [
['meeting', '📅'],
['commuting', '🚌'],
['sick-leave', '🤒'],
['vacationing', '🌴'],
['remote-work', '🏡'],
+ ['be-right-back', '⏳'],
['call', '💬'],
['unknown-id', null],
];
}
- /**
- * @param string $id
- * @param string|null $expected
- *
- * @dataProvider getTranslatedStatusForIdDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('getTranslatedStatusForIdDataProvider')]
public function testGetTranslatedStatusForId(string $id, ?string $expected): void {
$this->l10n->method('t')
->willReturnArgument(0);
@@ -136,49 +130,40 @@ class PredefinedStatusServiceTest extends TestCase {
$this->assertEquals($expected, $actual);
}
- /**
- * @return array
- */
- public function getTranslatedStatusForIdDataProvider(): array {
+ public static function getTranslatedStatusForIdDataProvider(): array {
return [
['meeting', 'In a meeting'],
['commuting', 'Commuting'],
['sick-leave', 'Out sick'],
['vacationing', 'Vacationing'],
['remote-work', 'Working remotely'],
+ ['be-right-back', 'Be right back'],
['call', 'In a call'],
['unknown-id', null],
];
}
- /**
- * @param string $id
- * @param bool $expected
- *
- * @dataProvider isValidIdDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('isValidIdDataProvider')]
public function testIsValidId(string $id, bool $expected): void {
$actual = $this->service->isValidId($id);
$this->assertEquals($expected, $actual);
}
- /**
- * @return array
- */
- public function isValidIdDataProvider(): array {
+ public static function isValidIdDataProvider(): array {
return [
['meeting', true],
['commuting', true],
['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);