1010
1111use OCA \Libresign \Service \Policy \Model \PolicyContext ;
1212use OCA \Libresign \Service \Policy \Provider \Footer \AddFooterPolicy ;
13+ use OCA \Libresign \Service \Policy \Provider \Footer \SignatureFooterPolicyValue ;
1314use PHPUnit \Framework \TestCase ;
1415
1516final class AddFooterPolicyTest extends TestCase {
@@ -19,19 +20,45 @@ public function testProviderBuildsAddFooterDefinition(): void {
1920 $ definition = $ provider ->get (AddFooterPolicy::KEY );
2021
2122 $ this ->assertSame (AddFooterPolicy::KEY , $ definition ->key ());
22- $ this ->assertTrue ($ definition ->defaultSystemValue ());
23- $ this ->assertSame ([true , false ], $ definition ->allowedValues (new PolicyContext ()));
23+ $ this ->assertSame (
24+ SignatureFooterPolicyValue::encode (SignatureFooterPolicyValue::defaults ()),
25+ $ definition ->defaultSystemValue (),
26+ );
27+ $ this ->assertSame ([], $ definition ->allowedValues (new PolicyContext ()));
2428 }
2529
2630 public function testProviderNormalizesBooleanLikeValues (): void {
2731 $ provider = new AddFooterPolicy ();
2832 $ definition = $ provider ->get (AddFooterPolicy::KEY );
2933
30- $ this ->assertTrue ($ definition ->normalizeValue (true ));
31- $ this ->assertFalse ($ definition ->normalizeValue (false ));
32- $ this ->assertTrue ($ definition ->normalizeValue ('1 ' ));
33- $ this ->assertFalse ($ definition ->normalizeValue ('0 ' ));
34- $ this ->assertTrue ($ definition ->normalizeValue ('true ' ));
35- $ this ->assertFalse ($ definition ->normalizeValue ('false ' ));
34+ $ this ->assertSame (
35+ SignatureFooterPolicyValue::encode ([
36+ 'enabled ' => true ,
37+ 'writeQrcodeOnFooter ' => true ,
38+ 'validationSite ' => '' ,
39+ 'customizeFooterTemplate ' => false ,
40+ ]),
41+ $ definition ->normalizeValue (true ),
42+ );
43+
44+ $ this ->assertSame (
45+ SignatureFooterPolicyValue::encode ([
46+ 'enabled ' => false ,
47+ 'writeQrcodeOnFooter ' => true ,
48+ 'validationSite ' => '' ,
49+ 'customizeFooterTemplate ' => false ,
50+ ]),
51+ $ definition ->normalizeValue ('0 ' ),
52+ );
53+
54+ $ this ->assertSame (
55+ SignatureFooterPolicyValue::encode ([
56+ 'enabled ' => true ,
57+ 'writeQrcodeOnFooter ' => false ,
58+ 'validationSite ' => 'https://validation.example ' ,
59+ 'customizeFooterTemplate ' => true ,
60+ ]),
61+ $ definition ->normalizeValue ('{"enabled":true,"writeQrcodeOnFooter":false,"validationSite":"https://validation.example","customizeFooterTemplate":true} ' ),
62+ );
3663 }
3764}
0 commit comments