@@ -274,6 +274,8 @@ public function testGetAllowedExtensionsByType()
274
274
*/
275
275
public function testGetThumbnailPathNotFound ()
276
276
{
277
+ $ this ->filesystemDriver ->method ('getRealpathSafety ' )
278
+ ->willReturnArgument (0 );
277
279
$ image = 'notFoundImage.png ' ;
278
280
$ root = '/image ' ;
279
281
$ sourceNode = '/not/a/root ' ;
@@ -452,6 +454,20 @@ public function testGetThemeNotFound()
452
454
$ helper ->getStorageRoot ();
453
455
}
454
456
457
+ /**
458
+ * @dataProvider getCurrentPathDataProvider
459
+ */
460
+ public function testGetCurrentPathCachesResult ()
461
+ {
462
+ $ this ->request ->expects ($ this ->once ())
463
+ ->method ('getParam ' )
464
+ ->with (Storage::PARAM_NODE )
465
+ ->willReturn (Storage::NODE_ROOT );
466
+
467
+ $ actualPath = $ this ->helper ->getCurrentPath ();
468
+ self ::assertSame ('/image ' , $ actualPath );
469
+ }
470
+
455
471
/**
456
472
* @dataProvider getCurrentPathDataProvider
457
473
*/
@@ -479,8 +495,7 @@ public function testGetCurrentPath(
479
495
->willReturnArgument (0 );
480
496
}
481
497
482
- $ this ->request ->expects ($ this ->once ())
483
- ->method ('getParam ' )
498
+ $ this ->request ->method ('getParam ' )
484
499
->with (Storage::PARAM_NODE )
485
500
->willReturn ($ requestedPath );
486
501
@@ -494,11 +509,11 @@ public function getCurrentPathDataProvider(): array
494
509
$ rootPath = '/ ' . \Magento \Theme \Model \Wysiwyg \Storage::TYPE_IMAGE ;
495
510
496
511
return [
497
- [$ rootPath , Storage::NODE_ROOT ],
498
- [$ rootPath , $ rootPath . '/foo ' ],
499
- [ $ rootPath , $ rootPath . ' /something ' , true , null , ' /bar ' ],
500
- [ ' foo/ ' , $ rootPath . '/foo ' , true , ' foo/ ' ],
501
- [ $ rootPath , $ rootPath . '/foo ' , false ],
512
+ ' requested path "root" should short-circuit ' => [$ rootPath , Storage::NODE_ROOT ],
513
+ ' non-existent directory should default to the base path ' => [$ rootPath , $ rootPath . '/foo ' ],
514
+ ' requested path that resolves to a bad path should default to root ' =>
515
+ [ $ rootPath , $ rootPath . '/something ' , true , null , ' /bar ' ],
516
+ ' real path should resolve to relative path ' => [ ' foo/ ' , $ rootPath . '/foo ' , true , ' foo/ ' ],
502
517
];
503
518
}
504
519
}
0 commit comments