Skip to content

Commit c756ff7

Browse files
author
Vitor Mattos
committed
chore: cover with unit tests
Signed-off-by: Vitor Mattos <[email protected]>
1 parent fca0b7d commit c756ff7

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/Unit/Handler/JSignPdfHandlerTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use OCA\Libresign\Service\SignatureBackgroundService;
1515
use OCA\Libresign\Service\SignatureTextService;
1616
use OCP\IAppConfig;
17-
use PHPUnit\Framework\Attributes\DataProvider;
1817
use OCP\ITempManager;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1919
use PHPUnit\Framework\MockObject\MockObject;
2020
use Psr\Log\LoggerInterface;
2121

@@ -104,4 +104,30 @@ public static function providerGetJSignParam(): array {
104104
[sys_get_temp_dir(), __FILE__, '', true],
105105
];
106106
}
107+
108+
#[DataProvider('providerGetSignatureText')]
109+
public function testGetSignatureText(string $renderMode, string $template, string $expected): void {
110+
$this->signatureTextService->method('parse')
111+
->willReturn(['parsed' => trim($template, '"')]);
112+
$this->signatureTextService->method('getRenderMode')
113+
->willReturn($renderMode);
114+
$jSignPdfHandler = $this->getClass();
115+
$actual = $jSignPdfHandler->getSignatureText();
116+
$this->assertEquals($expected, $actual);
117+
}
118+
119+
public static function providerGetSignatureText(): array {
120+
return [
121+
['FAKE_RENDER_MODE', '', '""'],
122+
['FAKE_RENDER_MODE', 'a', '"a"'],
123+
['FAKE_RENDER_MODE', "a\na", "\"a\na\""],
124+
['FAKE_RENDER_MODE', 'a"a', '"a\"a"'],
125+
['FAKE_RENDER_MODE', 'a$a', '"a\$a"'],
126+
['GRAPHIC_ONLY', '', '""'],
127+
['GRAPHIC_ONLY', 'a', '""'],
128+
['GRAPHIC_ONLY', "a\na", '""'],
129+
['GRAPHIC_ONLY', 'a"a', '""'],
130+
['GRAPHIC_ONLY', 'a$a', '""'],
131+
];
132+
}
107133
}

0 commit comments

Comments
 (0)