Skip to content

Commit 54c04a7

Browse files
committed
test(policy): add structured signature footer value normalization tests
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3c8f54c commit 54c04a7

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\Footer;
10+
11+
use OCA\Libresign\Service\Policy\Provider\Footer\SignatureFooterPolicyValue;
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class SignatureFooterPolicyValueTest extends TestCase {
15+
public function testDefaultsAreStable(): void {
16+
$this->assertSame([
17+
'enabled' => true,
18+
'writeQrcodeOnFooter' => true,
19+
'validationSite' => '',
20+
'customizeFooterTemplate' => false,
21+
], SignatureFooterPolicyValue::defaults());
22+
}
23+
24+
public function testNormalizeLegacyBooleanInput(): void {
25+
$this->assertSame([
26+
'enabled' => false,
27+
'writeQrcodeOnFooter' => true,
28+
'validationSite' => '',
29+
'customizeFooterTemplate' => false,
30+
], SignatureFooterPolicyValue::normalize('0'));
31+
}
32+
33+
public function testNormalizeStructuredJsonInput(): void {
34+
$normalized = SignatureFooterPolicyValue::normalize(
35+
'{"enabled":true,"writeQrcodeOnFooter":false,"validationSite":"https://validation.example","customizeFooterTemplate":true}'
36+
);
37+
38+
$this->assertSame([
39+
'enabled' => true,
40+
'writeQrcodeOnFooter' => false,
41+
'validationSite' => 'https://validation.example',
42+
'customizeFooterTemplate' => true,
43+
], $normalized);
44+
}
45+
46+
public function testEncodeReturnsCanonicalPayload(): void {
47+
$this->assertSame(
48+
'{"enabled":true,"writeQrcodeOnFooter":true,"validationSite":"","customizeFooterTemplate":false}',
49+
SignatureFooterPolicyValue::encode([
50+
'enabled' => true,
51+
'writeQrcodeOnFooter' => true,
52+
'validationSite' => '',
53+
'customizeFooterTemplate' => false,
54+
]),
55+
);
56+
}
57+
}

0 commit comments

Comments
 (0)