@@ -63,7 +63,7 @@ public static function dataHandle(): array {
6363 'partial archive disabled, no filtering, 1 blocked 1 non-blocked file => should fail event ' => [
6464 'folderPath ' => $ rootFromFolder ,
6565 'rootDownloadable ' => true ,
66- 'files ' => [" blocked.txt " => false , " allowed.txt " => true ],
66+ 'files ' => [' blocked.txt ' => false , ' allowed.txt ' => true ],
6767 'filesFilter ' => [],
6868 'allowPartialArchive ' => false ,
6969 'expectedSuccess ' => false ,
@@ -186,15 +186,16 @@ public function testHandle(
186186 ): void {
187187 $ fileNodes = [];
188188 $ fileNodesByName = [];
189+ $ folderPathFromUserRoot = "/user/files {$ folderPath }" ;
189190 foreach ($ files as $ relativePath => $ downloadable ) {
190- $ pathWithFolder = "{$ folderPath }/ {$ relativePath }" ;
191+ $ pathWithFolder = "{$ folderPathFromUserRoot }/ {$ relativePath }" ;
191192 $ file = $ this ->createSharedFile ($ downloadable , $ pathWithFolder );
192- $ fileNodesByName [$ pathWithFolder ] = $ file ;
193+ $ fileNodesByName [$ relativePath ] = $ file ;
193194 $ fileNodes [] = $ file ;
194195 }
195- $ folderPathFromUserRoot = "/user/files {$ folderPath }" ;
196196 $ folder = $ this ->createSharedFolder ($ rootDownloadable , $ folderPathFromUserRoot , $ fileNodes );
197197 $ this ->userFolder ->method ('get ' )->willReturnCallback (function (string $ path ) use ($ folderPath , $ fileNodesByName , $ folder ) {
198+ $ path = str_replace ($ folderPath . '/ ' , '' , $ path );
198199 return match (true ) {
199200 $ path === $ folderPath => $ folder ,
200201 isset ($ fileNodesByName [$ path ]) => $ fileNodesByName [$ path ],
@@ -209,18 +210,18 @@ public function testHandle(
209210 $ this ->assertSame ($ expectedMessage , $ event ->getErrorMessage ());
210211
211212 $ event ->setNodesIterable ($ fileNodes );
212- $ actualNodes = iterator_to_array ($ event ->getNodes ());
213+ $ actualNodes = iterator_to_array ($ event ->getNodes ($ folderPathFromUserRoot ));
213214 $ this ->assertCount (count ($ expectedNodeList ), $ actualNodes );
214215 foreach ($ expectedNodeList as $ relativePath => $ expectedValue ) {
215- $ path = "{ $ folderPath } / { $ relativePath} " ;
216+ $ path = "$ relativePath " ;
216217 if ($ expectedValue === null ) {
217218 // cannot reference the node in the data provider, add it here
218219 $ node = $ fileNodesByName [$ path ] ?? null ;
219220 $ this ->assertNotNull ($ node , 'Node mock must be present for the test to be correct. ' );
220221 $ expectedValue = [$ node , null ];
221222 }
222223
223- $ this ->assertEquals ($ expectedValue , $ actualNodes [$ path ]);
224+ $ this ->assertEquals ($ expectedValue , $ actualNodes [$ path ] ?? [] );
224225 }
225226 }
226227
0 commit comments