File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -342,7 +342,11 @@ public function getPdfByUuid(string $uuid): File {
342342
343343 $ userId = $ this ->fileMapper ->getStorageUserIdByUuid ($ uuid );
344344 $ this ->folderService ->setUserId ($ userId );
345- return $ this ->folderService ->getFileByNodeId ($ nodeId );
345+ try {
346+ return $ this ->folderService ->getFileByNodeId ($ nodeId );
347+ } catch (NotFoundException ) {
348+ throw new DoesNotExistException ('Not found ' );
349+ }
346350 }
347351
348352 public function getFileByNodeId (int $ nodeId ): File {
Original file line number Diff line number Diff line change @@ -307,6 +307,46 @@ public function testGetPdfByUuidWithSuccessAndUnignedFile():void {
307307 $ this ->assertInstanceOf (\OCP \Files \File::class, $ actual );
308308 }
309309
310+ public function testGetPdfByUuidThrowsDoesNotExistWhenNodeNotFound (): void {
311+ $ libresignFile = $ this ->createMock (\OCA \Libresign \Db \File::class);
312+ $ libresignFile ->method ('__call ' )
313+ ->willReturnCallback (fn ($ method )
314+ => match ($ method ) {
315+ 'getSignedNodeId ' => null ,
316+ 'getNodeId ' => 123 ,
317+ 'getStatus ' => \OCA \Libresign \Enum \FileStatus::DRAFT ->value ,
318+ }
319+ );
320+
321+ $ this ->fileMapper
322+ ->expects ($ this ->once ())
323+ ->method ('getByUuid ' )
324+ ->with ('uuid ' )
325+ ->willReturn ($ libresignFile );
326+
327+ $ this ->fileMapper
328+ ->expects ($ this ->once ())
329+ ->method ('getStorageUserIdByUuid ' )
330+ ->with ('uuid ' )
331+ ->willReturn ('guest-user ' );
332+
333+ $ this ->folderService
334+ ->expects ($ this ->once ())
335+ ->method ('setUserId ' )
336+ ->with ('guest-user ' );
337+
338+ $ this ->folderService
339+ ->expects ($ this ->once ())
340+ ->method ('getFileByNodeId ' )
341+ ->with (123 )
342+ ->willThrowException (new NotFoundException ('Invalid node ' ));
343+
344+ $ this ->expectException (DoesNotExistException::class);
345+ $ this ->expectExceptionMessage ('Not found ' );
346+
347+ $ this ->getService ()->getPdfByUuid ('uuid ' );
348+ }
349+
310350 public function testCanRequestSignWithUnexistentUser ():void {
311351 $ actual = $ this ->getService ()->canRequestSign ();
312352 $ this ->assertFalse ($ actual );
You can’t perform that action at this time.
0 commit comments