|
14 | 14 | use OCA\Libresign\Service\SignatureBackgroundService;
|
15 | 15 | use OCA\Libresign\Service\SignatureTextService;
|
16 | 16 | use OCP\IAppConfig;
|
17 |
| -use PHPUnit\Framework\Attributes\DataProvider; |
18 | 17 | use OCP\ITempManager;
|
| 18 | +use PHPUnit\Framework\Attributes\DataProvider; |
19 | 19 | use PHPUnit\Framework\MockObject\MockObject;
|
20 | 20 | use Psr\Log\LoggerInterface;
|
21 | 21 |
|
@@ -104,4 +104,30 @@ public static function providerGetJSignParam(): array {
|
104 | 104 | [sys_get_temp_dir(), __FILE__, '', true],
|
105 | 105 | ];
|
106 | 106 | }
|
| 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 | + } |
107 | 133 | }
|
0 commit comments