@@ -339,13 +339,14 @@ public function providerIsUsingStaticUrlsAllowed()
339
339
* @param bool $isExist
340
340
* @dataProvider providerGetCurrentPath
341
341
*/
342
- public function testGetCurrentPath ($ pathId , $ expectedPath , $ isExist )
342
+ public function testGetCurrentPath ($ pathId , $ subDir , $ expectedPath , $ isExist )
343
343
{
344
344
$ this ->requestMock ->expects ($ this ->any ())
345
345
->method ('getParam ' )
346
346
->willReturnMap (
347
347
[
348
348
['node ' , null , $ pathId ],
349
+ ['current_tree_path ' , null , $ subDir ],
349
350
]
350
351
);
351
352
@@ -367,21 +368,33 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist)
367
368
['PATH ' , '. ' ],
368
369
]
369
370
);
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
+ }
376
380
377
381
$ this ->assertEquals ($ expectedPath , $ this ->imagesHelper ->getCurrentPath ());
378
382
}
379
383
380
384
public function testGetCurrentPathThrowException ()
381
385
{
386
+ $ this ->requestMock ->expects ($ this ->any ())
387
+ ->method ('getParam ' )
388
+ ->willReturn ('PATH ' );
389
+
382
390
$ 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
+ );
384
394
395
+ $ this ->directoryWriteMock ->expects ($ this ->any ())
396
+ ->method ('getRelativePath ' )
397
+ ->willReturn ('SUBDIR ' );
385
398
$ this ->directoryWriteMock ->expects ($ this ->once ())
386
399
->method ('isExist ' )
387
400
->willReturn (false );
@@ -402,12 +415,12 @@ public function testGetCurrentPathThrowException()
402
415
public function providerGetCurrentPath ()
403
416
{
404
417
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 ],
411
424
];
412
425
}
413
426
0 commit comments