Skip to content

Commit ea9e2ea

Browse files
committed
test: assert envelope child includes file URL
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 56eb290 commit ea9e2ea

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/php/Unit/Service/File/EnvelopeAssemblerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use OCP\Files\File;
2424
use OCP\Files\Folder;
2525
use OCP\Files\IRootFolder;
26+
use OCP\IURLGenerator;
2627
use PHPUnit\Framework\Attributes\DataProvider;
2728
use PHPUnit\Framework\MockObject\MockObject;
2829
use Psr\Log\NullLogger;
@@ -32,6 +33,7 @@ final class EnvelopeAssemblerTest extends \OCA\Libresign\Tests\Unit\TestCase {
3233
private IdentifyMethodService&MockObject $identifyMethodService;
3334
private FileMapper&MockObject $fileMapper;
3435
private IRootFolder&MockObject $root;
36+
private IURLGenerator&MockObject $urlGenerator;
3537
private SignersLoader&MockObject $signersLoader;
3638
private Pkcs12Handler&MockObject $pkcs12Handler;
3739
private FileElementService&MockObject $fileElementService;
@@ -42,6 +44,7 @@ public function setUp(): void {
4244
$this->identifyMethodService = $this->createMock(IdentifyMethodService::class);
4345
$this->fileMapper = $this->createMock(FileMapper::class);
4446
$this->root = $this->createMock(IRootFolder::class);
47+
$this->urlGenerator = $this->createMock(IURLGenerator::class);
4548
$this->signersLoader = $this->createMock(SignersLoader::class);
4649
$this->pkcs12Handler = $this->createMock(Pkcs12Handler::class);
4750
$this->fileElementService = $this->createMock(FileElementService::class);
@@ -53,6 +56,7 @@ private function getService(): EnvelopeAssembler {
5356
$this->identifyMethodService,
5457
$this->fileMapper,
5558
$this->root,
59+
$this->urlGenerator,
5660
$this->signersLoader,
5761
null,
5862
$this->pkcs12Handler,
@@ -66,6 +70,7 @@ private function mockFileNode(): void {
6670
$fileNode = $this->createMock(File::class);
6771
$folder->method('getFirstNodeById')->willReturn($fileNode);
6872
$this->root->method('getUserFolder')->willReturn($folder);
73+
$this->urlGenerator->method('linkToRoute')->willReturn('http://example.com/page.pdf');
6974
}
7075

7176
public function testBuildsChildDataWithoutCertificateChain(): void {
@@ -104,6 +109,7 @@ public function testBuildsChildDataWithoutCertificateChain(): void {
104109
$this->assertIsObject($result);
105110
$this->assertEquals(7, $result->id);
106111
$this->assertEquals('child.pdf', $result->name);
112+
$this->assertSame('http://example.com/page.pdf', $result->file);
107113
$this->assertIsArray($result->signers);
108114
$this->assertCount(1, $result->signers);
109115
$this->assertEquals(42, $result->signers[0]->signRequestId);

0 commit comments

Comments
 (0)