Skip to content

Commit 6a744c3

Browse files
committed
test: add tests/php/Unit/Service/Policy/Provider/Reminder/ReminderPolicyTest.php
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 1690005 commit 6a744c3

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
9+
namespace OCA\Libresign\Tests\Unit\Service\Policy\Provider\Reminder;
10+
11+
use OCA\Libresign\Service\Policy\Provider\Reminder\ReminderPolicy;
12+
use OCA\Libresign\Service\Policy\Provider\Reminder\ReminderPolicyValue;
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class ReminderPolicyTest extends TestCase {
16+
public function testProviderBuildsReminderDefinition(): void {
17+
$provider = new ReminderPolicy();
18+
$this->assertSame([ReminderPolicy::KEY], $provider->keys());
19+
20+
$definition = $provider->get(ReminderPolicy::KEY);
21+
$this->assertSame(ReminderPolicy::KEY, $definition->key());
22+
$this->assertSame(
23+
ReminderPolicyValue::encode(ReminderPolicyValue::defaults()),
24+
$definition->defaultSystemValue(),
25+
);
26+
}
27+
28+
public function testProviderNormalizesReminderPayload(): void {
29+
$provider = new ReminderPolicy();
30+
$definition = $provider->get(ReminderPolicy::KEY);
31+
32+
$normalized = $definition->normalizeValue([
33+
'days_before' => '2',
34+
'days_between' => 3,
35+
'max' => '4',
36+
'send_timer' => '09:45',
37+
]);
38+
39+
$this->assertSame(
40+
'{"days_before":2,"days_between":3,"max":4,"send_timer":"09:45"}',
41+
$normalized,
42+
);
43+
}
44+
45+
public function testProviderNormalizesInvalidReminderPayload(): void {
46+
$provider = new ReminderPolicy();
47+
$definition = $provider->get(ReminderPolicy::KEY);
48+
49+
$normalized = $definition->normalizeValue([
50+
'days_before' => -5,
51+
'days_between' => 'not-number',
52+
'max' => -1,
53+
'send_timer' => 'invalid',
54+
]);
55+
56+
$this->assertSame(
57+
'{"days_before":0,"days_between":0,"max":0,"send_timer":"10:00"}',
58+
$normalized,
59+
);
60+
}
61+
}

0 commit comments

Comments
 (0)