@@ -149,14 +149,6 @@ public function testValidateNotRequestedSignWithSuccessWhenNotFound():void {
149149 $ this ->assertNull ($ actual );
150150 }
151151
152- public function testValidateLibreSignNodeIdWhenFileIdNotExists ():void {
153- $ this ->signRequestMapper ->method ('getByNodeId ' )->willReturnCallback (function ():void {
154- throw new \Exception ('not found ' );
155- });
156- $ this ->expectExceptionMessage ('Invalid fileID ' );
157- $ this ->getValidateHelper ()->validateLibreSignNodeId (1 );
158- }
159-
160152 /**
161153 * @dataProvider dataValidateMimeTypeAcceptedByNodeId
162154 */
@@ -189,23 +181,25 @@ public static function dataValidateMimeTypeAcceptedByNodeId():array {
189181 ];
190182 }
191183
192- public function testValidateLibreSignNodeIdWhenSuccess ():void {
184+ public function testValidateMimeTypeAcceptedByNodeIdWhenSuccess ():void {
193185 $ libresignFile = $ this ->createMock (\OCA \Libresign \Db \File::class);
186+ $ libresignFile ->method ('getUserId ' )->willReturn ('user1 ' );
194187 $ this ->fileMapper
195- ->method ('getByFileId ' )
188+ ->method ('getByNodeId ' )
196189 ->willReturn ($ libresignFile );
197190 $ file = $ this ->createMock (\OCP \Files \File::class);
198191 $ file
199192 ->method ('getMimeType ' )
200193 ->willReturn ('application/pdf ' );
201194 $ folder = $ this ->createMock (\OCP \Files \Folder::class);
202195 $ folder
203- ->method ('getById ' )
204- ->willReturn ([ $ file] );
196+ ->method ('getFirstNodeById ' )
197+ ->willReturn ($ file );
205198 $ this ->root
206199 ->method ('getUserFolder ' )
200+ ->with ('user1 ' )
207201 ->willReturn ($ folder );
208- $ actual = $ this ->getValidateHelper ()->validateLibreSignNodeId (1 );
202+ $ actual = $ this ->getValidateHelper ()->validateMimeTypeAcceptedByNodeId (1 );
209203 $ this ->assertNull ($ actual );
210204 }
211205
@@ -305,7 +299,7 @@ public function testIRequestedSignThisFileWithInvalidRequester():void {
305299 ->method ('__call ' )
306300 ->willReturn ('user1 ' );
307301 $ this ->fileMapper
308- ->method ('getByFileId ' )
302+ ->method ('getById ' )
309303 ->willReturn ($ libresignFile );
310304 $ user = $ this ->createMock (\OCP \IUser::class);
311305 $ user
@@ -330,45 +324,6 @@ public static function dataProviderHaveValidMail():array {
330324 ];
331325 }
332326
333- public function testSignerWasAssociatedWithNotLibreSignFileLoaded ():void {
334- $ this ->expectExceptionMessage ('File not loaded ' );
335- $ this ->fileMapper
336- ->method ('getByFileId ' )
337- ->willReturnCallback (function ():void {
338- throw new \Exception ('not found ' );
339- });
340- $ this ->getValidateHelper ()->signerWasAssociated ([
341- 342- ]);
343- }
344-
345- public function testSignerWasAssociatedWithUnassociatedSigner ():void {
346- $ this ->expectExceptionMessage ('No signature was requested to %s ' );
347- $ libresignFile = $ this ->createMock (\OCA \Libresign \Db \File::class);
348- $ libresignFile
349- ->method ('__call ' )
350- ->willReturn ('uuid ' );
351- $ this ->fileMapper
352- ->method ('getByFileId ' )
353- ->willReturn ($ libresignFile );
354- $ this ->signRequestMapper
355- ->method ('getByFileUuid ' )
356- ->willReturn ([]);
357- $ this ->getValidateHelper ()->signerWasAssociated ([
358- 359- ]);
360- }
361-
362- public function testNotSignedWithFileNotLoaded ():void {
363- $ this ->expectExceptionMessage ('File not loaded ' );
364- $ this ->fileMapper
365- ->method ('getByFileId ' )
366- ->willReturnCallback (function ():void {
367- throw new \Exception ('not found ' );
368- });
369- $ this ->getValidateHelper ()->notSigned ([]);
370- }
371-
372327 public function testValidateIfNodeIdExistsWhenUserNotFound ():void {
373328 $ this ->expectExceptionMessage ('User not found ' );
374329 $ userFolder = $ this ->createMock (\OCP \Files \Folder::class);
@@ -556,18 +511,19 @@ public function testValidateExistingFile($dataFile, $uuid, $exception):void {
556511 ->willReturnCallback (fn ($ method )
557512 => match ($ method ) {
558513 'getNodeId ' => 1 ,
514+ 'getId ' => 1 ,
559515 }
560516 );
561517 $ libresignFile ->method ('getUserId ' )
562518 ->willReturn ('fake_user ' );
563519 $ this ->fileMapper ->method ('getByUuid ' )->willReturn ($ libresignFile );
564- $ this ->fileMapper ->method ('getByFileId ' )->willReturn ($ libresignFile );
520+ $ this ->fileMapper ->method ('getById ' )->willReturn ($ libresignFile );
565521
566522 $ data ['uuid ' ] = $ uuid ;
567523 } elseif (!empty ($ dataFile )) {
568524 $ libresignFile ->method ('getUserId ' )
569525 ->willReturn ('fake_user ' );
570- $ this ->fileMapper ->method ('getByFileId ' )->willReturn ($ libresignFile );
526+ $ this ->fileMapper ->method ('getById ' )->willReturn ($ libresignFile );
571527
572528 $ file = $ this ->createMock (\OCP \Files \File::class);
573529 $ file
0 commit comments