2323use OCP \Files \File ;
2424use OCP \Files \Folder ;
2525use OCP \Files \IRootFolder ;
26+ use OCP \IURLGenerator ;
2627use PHPUnit \Framework \Attributes \DataProvider ;
2728use PHPUnit \Framework \MockObject \MockObject ;
2829use 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