@@ -339,13 +339,14 @@ public function providerIsUsingStaticUrlsAllowed()
339339 * @param bool $isExist
340340 * @dataProvider providerGetCurrentPath
341341 */
342- public function testGetCurrentPath ($ pathId , $ expectedPath , $ isExist )
342+ public function testGetCurrentPath ($ pathId , $ subDir , $ expectedPath , $ isExist )
343343 {
344344 $ this ->requestMock ->expects ($ this ->any ())
345345 ->method ('getParam ' )
346346 ->willReturnMap (
347347 [
348348 ['node ' , null , $ pathId ],
349+ ['current_tree_path ' , null , $ subDir ],
349350 ]
350351 );
351352
@@ -367,21 +368,33 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist)
367368 ['PATH ' , '. ' ],
368369 ]
369370 );
370- $ this ->directoryWriteMock ->expects ($ this ->once ())
371- ->method ('isExist ' )
372- ->willReturn ($ isExist );
373- $ this ->directoryWriteMock ->expects ($ this ->any ())
374- ->method ('create ' )
375- ->with ($ this ->directoryWriteMock ->getRelativePath ($ expectedPath ));
371+
372+ if ($ subDir ) {
373+ $ this ->directoryWriteMock ->expects ($ this ->once ())
374+ ->method ('isExist ' )
375+ ->willReturn ($ isExist );
376+ $ this ->directoryWriteMock ->expects ($ this ->any ())
377+ ->method ('create ' )
378+ ->with ($ this ->directoryWriteMock ->getRelativePath ($ expectedPath ));
379+ }
376380
377381 $ this ->assertEquals ($ expectedPath , $ this ->imagesHelper ->getCurrentPath ());
378382 }
379383
380384 public function testGetCurrentPathThrowException ()
381385 {
386+ $ this ->requestMock ->expects ($ this ->any ())
387+ ->method ('getParam ' )
388+ ->willReturn ('PATH ' );
389+
382390 $ this ->expectException (\Magento \Framework \Exception \LocalizedException::class);
383- $ this ->expectExceptionMessage ('The directory PATH is not writable by server. ' );
391+ $ this ->expectExceptionMessage (
392+ 'Can \'t create SUBDIR as subdirectory of PATH, you might have some permission issue. '
393+ );
384394
395+ $ this ->directoryWriteMock ->expects ($ this ->any ())
396+ ->method ('getRelativePath ' )
397+ ->willReturn ('SUBDIR ' );
385398 $ this ->directoryWriteMock ->expects ($ this ->once ())
386399 ->method ('isExist ' )
387400 ->willReturn (false );
@@ -402,12 +415,12 @@ public function testGetCurrentPathThrowException()
402415 public function providerGetCurrentPath ()
403416 {
404417 return [
405- ['L3Rlc3RfcGF0aA-- ' , 'PATH/test_path ' , true ],
406- ['L215LmpwZw-- ' , 'PATH ' , true ],
407- [null , 'PATH ' , true ],
408- ['L3Rlc3RfcGF0aA-- ' , 'PATH/test_path ' , false ],
409- ['L215LmpwZw-- ' , 'PATH ' , false ],
410- [null , 'PATH ' , false ],
418+ ['L3Rlc3RfcGF0aA-- ' , 'L3Rlc3RfcGF0aA-- ' , ' PATH/test_path ' , true ],
419+ ['L215LmpwZw-- ' , '' , ' PATH ' , true ],
420+ [null , '' , ' PATH ' , true ],
421+ ['L3Rlc3RfcGF0aA-- ' , 'L3Rlc3RfcGF0aA-- ' , ' PATH/test_path ' , false ],
422+ ['L215LmpwZw-- ' , '' , ' PATH ' , false ],
423+ [null , '' , ' PATH ' , false ],
411424 ];
412425 }
413426
0 commit comments