|
18 | 18 | use OCA\Libresign\Service\File\SignersLoader; |
19 | 19 | use OCA\Libresign\Service\FileElementService; |
20 | 20 | use OCA\Libresign\Service\IdentifyMethodService; |
| 21 | +use OCP\Files\File; |
| 22 | +use OCP\Files\Folder; |
21 | 23 | use OCP\Files\IRootFolder; |
22 | 24 | use PHPUnit\Framework\MockObject\MockObject; |
23 | 25 | use Psr\Log\NullLogger; |
@@ -56,7 +58,16 @@ private function getService(): EnvelopeAssembler { |
56 | 58 | ); |
57 | 59 | } |
58 | 60 |
|
| 61 | + private function mockFileNode(): void { |
| 62 | + $folder = $this->createMock(Folder::class); |
| 63 | + $fileNode = $this->createMock(File::class); |
| 64 | + $folder->method('getFirstNodeById')->willReturn($fileNode); |
| 65 | + $this->root->method('getUserFolder')->willReturn($folder); |
| 66 | + } |
| 67 | + |
59 | 68 | public function testBuildsChildDataWithoutCertificateChain(): void { |
| 69 | + $this->mockFileNode(); |
| 70 | + |
60 | 71 | $signRequest = new DbSignRequest(); |
61 | 72 | $signRequest->setId(42); |
62 | 73 | $signRequest->setSigned(null); |
@@ -96,6 +107,8 @@ public function testBuildsChildDataWithoutCertificateChain(): void { |
96 | 107 | } |
97 | 108 |
|
98 | 109 | public function testBuildsChildDataWithVisibleElements(): void { |
| 110 | + $this->mockFileNode(); |
| 111 | + |
99 | 112 | $signRequest = new DbSignRequest(); |
100 | 113 | $signRequest->setId(100); |
101 | 114 | $signRequest->setDisplayName('Signer A'); |
@@ -148,6 +161,8 @@ public function testBuildsChildDataWithVisibleElements(): void { |
148 | 161 | } |
149 | 162 |
|
150 | 163 | public function testBuildsChildDataWithoutVisibleElementsWhenNotRequested(): void { |
| 164 | + $this->mockFileNode(); |
| 165 | + |
151 | 166 | $signRequest = new DbSignRequest(); |
152 | 167 | $signRequest->setId(50); |
153 | 168 | $signRequest->setDisplayName('Signer B'); |
@@ -182,6 +197,8 @@ public function testBuildsChildDataWithoutVisibleElementsWhenNotRequested(): voi |
182 | 197 | } |
183 | 198 |
|
184 | 199 | public function testBuildsChildDataWithMultipleSigners(): void { |
| 200 | + $this->mockFileNode(); |
| 201 | + |
185 | 202 | $signer1 = new DbSignRequest(); |
186 | 203 | $signer1->setId(1); |
187 | 204 | $signer1->setDisplayName('Alice'); |
|
0 commit comments