2727use OCP \Files \File ;
2828use OCP \Files \Folder ;
2929use OCP \Files \IRootFolder ;
30- use OCP \Files \NotFoundException ;
3130use PHPUnit \Framework \Attributes \DataProvider ;
3231use PHPUnit \Framework \MockObject \MockObject ;
3332
@@ -57,7 +56,7 @@ public function getCache(array $methods = []): ViewInfoCache|MockObject {
5756 public static function dataGetInfoById (): array {
5857 return [
5958 [
60- 'user ' , 23 , 'path ' , [], true , 'findInfoById ' ,
59+ 'user ' , 23 , 'path ' , [], true , [ 'findInfoById ' ] ,
6160 ],
6261 [
6362 'user ' ,
@@ -69,7 +68,7 @@ public static function dataGetInfoById(): array {
6968 ]
7069 ],
7170 true ,
72- 'findInfoById ' ,
71+ [ 'findInfoById ' ] ,
7372 ],
7473 [
7574 'user ' ,
@@ -81,7 +80,7 @@ public static function dataGetInfoById(): array {
8180 ]
8281 ],
8382 true ,
84- 'findInfoById ' ,
83+ [ 'findInfoById ' ] ,
8584 ],
8685 [
8786 'user ' ,
@@ -111,15 +110,15 @@ public static function dataGetInfoById(): array {
111110 }
112111
113112 #[DataProvider('dataGetInfoById ' )]
114- public function testGetInfoById (string $ user , int $ id , string |array $ path , array $ cache , bool $ callsFind , string | array $ expected ): void {
113+ public function testGetInfoById (string $ user , int $ id , string |array $ path , array $ cache , bool $ callsFind , array $ expected ): void {
115114 $ infoCache = $ this ->getCache ([
116115 'findInfoById ' ,
117116 ]);
118117
119118 if ($ callsFind ) {
120119 $ infoCache ->expects ($ this ->once ())
121120 ->method ('findInfoById ' )
122- ->willReturn ('findInfoById ' );
121+ ->willReturn ([ 'findInfoById ' ] );
123122 } else {
124123 $ infoCache ->expects ($ this ->never ())
125124 ->method ('findInfoById ' );
@@ -239,9 +238,9 @@ public function testFindInfoById(string $user, int $fileId, string $filename, ?s
239238 ->willReturn ($ userFolder );
240239 if ($ path === null ) {
241240 $ userFolder ->expects ($ this ->once ())
242- ->method ('getById ' )
241+ ->method ('getFirstNodeById ' )
243242 ->with ($ fileId )
244- ->willThrowException ( new NotFoundException () );
243+ ->willReturn ( null );
245244
246245 $ userTrashBin = $ this ->createMock (Folder::class);
247246 $ this ->rootFolder ->expects ($ this ->once ())
@@ -250,9 +249,9 @@ public function testFindInfoById(string $user, int $fileId, string $filename, ?s
250249 ->willReturn ($ userTrashBin );
251250 if ($ pathTrash === null ) {
252251 $ userTrashBin ->expects ($ this ->once ())
253- ->method ('getById ' )
252+ ->method ('getFirstNodeById ' )
254253 ->with ($ fileId )
255- ->willThrowException ( new NotFoundException () );
254+ ->willReturn ( null );
256255 } else {
257256 $ node = $ this ->createMock ($ isDir ? Folder::class : File::class);
258257 $ node
@@ -264,9 +263,9 @@ public function testFindInfoById(string $user, int $fileId, string $filename, ?s
264263 ->willReturn ($ pathTrash );
265264
266265 $ userTrashBin ->expects ($ this ->once ())
267- ->method ('getById ' )
266+ ->method ('getFirstNodeById ' )
268267 ->with ($ fileId )
269- ->willReturn ([ 2 => $ node] );
268+ ->willReturn ($ node );
270269 $ expected ['node ' ] = $ node ;
271270 $ expectedCache [$ user ][$ fileId ]['node ' ] = $ node ;
272271 }
@@ -281,9 +280,9 @@ public function testFindInfoById(string $user, int $fileId, string $filename, ?s
281280 ->willReturn ($ path );
282281
283282 $ userFolder ->expects ($ this ->once ())
284- ->method ('getById ' )
283+ ->method ('getFirstNodeById ' )
285284 ->with ($ fileId )
286- ->willReturn ([ 3 => $ node] );
285+ ->willReturn ($ node );
287286 $ expected ['node ' ] = $ node ;
288287 $ expectedCache [$ user ][$ fileId ]['node ' ] = $ node ;
289288 }
0 commit comments