diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index 0688534dc4ad9..6d8c4ecd71127 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -735,7 +735,7 @@ protected function _validatePath($path) */ protected function _sanitizePath($path) { - return rtrim(preg_replace('~[/\\\]+~', '/', $this->_directory->getDriver()->getRealPath($path)), '/'); + return rtrim(preg_replace('~[/\\\]+~', '/', $this->_directory->getDriver()->getRealPathSafety($path)), '/'); } /** diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php index 805f6d042f94a..e09ad27e2b7ca 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php @@ -114,16 +114,11 @@ class StorageTest extends \PHPUnit\Framework\TestCase protected function setUp() { $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); - $this->driverMock = $this->getMockForAbstractClass( - \Magento\Framework\Filesystem\DriverInterface::class, - [], - '', - false, - false, - true, - ['getRealPath'] - ); + $this->driverMock = $this->getMockBuilder(\Magento\Framework\Filesystem\DriverInterface::class) + ->setMethods(['getRealPath', 'getRealPathSafety']) + ->getMockForAbstractClass(); $this->driverMock->expects($this->any())->method('getRealPath')->will($this->returnArgument(0)); + $this->driverMock->expects($this->any())->method('getRealPathSafety')->will($this->returnArgument(0)); $this->directoryMock = $this->createPartialMock( \Magento\Framework\Filesystem\Directory\Write::class, diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php index 1ac4482c0eb01..8da29210d2f4b 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php @@ -31,30 +31,29 @@ class DeleteFilesTest extends \PHPUnit\Framework\TestCase /** * @var string */ - private $fullDirectoryPath; + private $fileName = 'magento_small_image.jpg'; /** - * @var string + * @var \Magento\Framework\Filesystem */ - private $fileName = 'magento_small_image.jpg'; + private $filesystem; + + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; /** * @inheritdoc */ protected function setUp() { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryName = 'directory1'; - $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->filesystem = $this->objectManager->get(\Magento\Framework\Filesystem::class); /** @var \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper */ - $this->imagesHelper = $objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); - $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - $this->fullDirectoryPath = $this->imagesHelper->getStorageRoot() . '/' . $directoryName; - $this->mediaDirectory->create($this->mediaDirectory->getRelativePath($this->fullDirectoryPath)); - $filePath = $this->fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName; - $fixtureDir = realpath(__DIR__ . '/../../../../../Catalog/_files'); - copy($fixtureDir . '/' . $this->fileName, $filePath); - $this->model = $objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\DeleteFiles::class); + $this->imagesHelper = $this->objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $this->model = $this->objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\DeleteFiles::class); } /** @@ -65,17 +64,48 @@ protected function setUp() */ public function testExecute() { + $directoryName = 'directory1'; + $fullDirectoryPath = $this->imagesHelper->getStorageRoot() . '/' . $directoryName; + $this->mediaDirectory->create($this->mediaDirectory->getRelativePath($fullDirectoryPath)); + $filePath = $fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName; + $fixtureDir = realpath(__DIR__ . '/../../../../../Catalog/_files'); + copy($fixtureDir . '/' . $this->fileName, $filePath); + $this->model->getRequest()->setMethod('POST') ->setPostValue('files', [$this->imagesHelper->idEncode($this->fileName)]); - $this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath); + $this->model->getStorage()->getSession()->setCurrentPath($fullDirectoryPath); $this->model->execute(); $this->assertFalse( $this->mediaDirectory->isExist( - $this->mediaDirectory->getRelativePath($this->fullDirectoryPath . '/' . $this->fileName) + $this->mediaDirectory->getRelativePath($fullDirectoryPath . '/' . $this->fileName) ) ); } + /** + * Execute method with correct directory path and file name to check that files under linked media directory + * can be removed. + * + * @return void + * @magentoDataFixture Magento/Cms/_files/linked_media.php + */ + public function testExecuteWithLinkedMedia() + { + $directoryName = 'linked_media'; + $fullDirectoryPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB) + ->getAbsolutePath() . DIRECTORY_SEPARATOR . $directoryName; + $filePath = $fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName; + $fixtureDir = realpath(__DIR__ . '/../../../../../Catalog/_files'); + copy($fixtureDir . '/' . $this->fileName, $filePath); + + $wysiwygDir = $this->mediaDirectory->getAbsolutePath() . '/wysiwyg'; + $this->model->getRequest()->setMethod('POST') + ->setPostValue('files', [$this->imagesHelper->idEncode($this->fileName)]); + $this->model->getStorage()->getSession()->setCurrentPath($wysiwygDir); + $this->model->execute(); + $this->assertFalse(is_file($fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName)); + } + /** * @inheritdoc */ diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolderTest.php index a16525ce244b1..79d4a05aba3c4 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolderTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolderTest.php @@ -29,9 +29,9 @@ class DeleteFolderTest extends \PHPUnit\Framework\TestCase private $mediaDirectory; /** - * @var string + * @var \Magento\Framework\Filesystem */ - private $fullDirectoryPath; + private $filesystem; /** * @inheritdoc @@ -39,37 +39,56 @@ class DeleteFolderTest extends \PHPUnit\Framework\TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); - $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $this->filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); /** @var \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper */ $this->imagesHelper = $objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); - $this->fullDirectoryPath = $this->imagesHelper->getStorageRoot(); $this->model = $objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\DeleteFolder::class); } /** * Execute method with correct directory path to check that directories under WYSIWYG media directory * can be removed. - * - * @return void */ public function testExecute() { + $fullDirectoryPath = $this->imagesHelper->getStorageRoot(); $directoryName = DIRECTORY_SEPARATOR . 'NewDirectory'; $this->mediaDirectory->create( - $this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $directoryName) + $this->mediaDirectory->getRelativePath($fullDirectoryPath . $directoryName) ); $this->model->getRequest()->setParams(['node' => $this->imagesHelper->idEncode($directoryName)]); $this->model->execute(); $this->assertFalse( $this->mediaDirectory->isExist( $this->mediaDirectory->getRelativePath( - $this->fullDirectoryPath . $directoryName + $fullDirectoryPath . $directoryName ) ) ); } + /** + * Execute method with correct directory path to check that directories under linked media directory + * can be removed. + * + * @magentoDataFixture Magento/Cms/_files/linked_media.php + */ + public function testExecuteWithLinkedMedia() + { + $linkedDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::PUB); + $linkedDirectoryPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB) + ->getAbsolutePath() . 'linked_media'; + $directoryName = 'NewDirectory'; + + $linkedDirectory->create( + $linkedDirectory->getRelativePath($linkedDirectoryPath . DIRECTORY_SEPARATOR . $directoryName) + ); + $this->model->getRequest()->setParams(['node' => $this->imagesHelper->idEncode($directoryName)]); + $this->model->execute(); + $this->assertFalse(is_dir($linkedDirectoryPath . DIRECTORY_SEPARATOR . $directoryName)); + } + /** * @inheritdoc */ diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolderTest.php index f7600097c50b2..0632af20f8300 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolderTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolderTest.php @@ -26,12 +26,17 @@ class NewFolderTest extends \PHPUnit\Framework\TestCase /** * @var string */ - private $fullDirectoryPath; + private $dirName= 'NewDirectory'; /** - * @var string + * @var \Magento\Framework\Filesystem */ - private $dirName= 'NewDirectory'; + private $filesystem; + + /** + * @var \Magento\Cms\Helper\Wysiwyg\Images + */ + private $imagesHelper; /** * @inheritdoc @@ -39,34 +44,49 @@ class NewFolderTest extends \PHPUnit\Framework\TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); - $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $this->filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); /** @var \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper */ - $imagesHelper = $objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); - $this->fullDirectoryPath = $imagesHelper->getStorageRoot(); + $this->imagesHelper = $objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->model = $objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\NewFolder::class); } /** - * Execute method with correct directory path to check that new folder can be created under WYSIWYG media directory. - * - * @return void + * Execute method with correct directory path to check that new folder can be created under linked media directory. */ public function testExecute() { + $fullDirectoryPath = $this->imagesHelper->getStorageRoot(); $this->model->getRequest()->setMethod('POST') ->setPostValue('name', $this->dirName); - $this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath); + $this->model->getStorage()->getSession()->setCurrentPath($fullDirectoryPath); $this->model->execute(); $this->assertTrue( $this->mediaDirectory->isExist( $this->mediaDirectory->getRelativePath( - $this->fullDirectoryPath . DIRECTORY_SEPARATOR . $this->dirName + $fullDirectoryPath . DIRECTORY_SEPARATOR . $this->dirName ) ) ); } + /** + * Execute method with correct directory path to check that new folder can be created under WYSIWYG media directory. + * + * @magentoDataFixture Magento/Cms/_files/linked_media.php + */ + public function testExecuteWithLinkedMedia() + { + $linkedDirectoryPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB) + ->getAbsolutePath() . DIRECTORY_SEPARATOR . 'linked_media'; + $fullDirectoryPath = $this->imagesHelper->getStorageRoot(); + $this->model->getRequest()->setMethod('POST') + ->setPostValue('name', $this->dirName); + $this->model->getStorage()->getSession()->setCurrentPath($fullDirectoryPath); + $this->model->execute(); + $this->assertTrue(is_dir($linkedDirectoryPath . DIRECTORY_SEPARATOR . $this->dirName)); + } + /** * @inheritdoc */ diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/UploadTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/UploadTest.php index 1439ee145ab91..629d997a64f87 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/UploadTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/UploadTest.php @@ -26,29 +26,29 @@ class UploadTest extends \PHPUnit\Framework\TestCase /** * @var string */ - private $fullDirectoryPath; + private $fileName = 'magento_small_image.jpg'; /** - * @var string + * @var \Magento\Framework\Filesystem */ - private $fileName = 'magento_small_image.jpg'; + private $filesystem; + + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; /** * @inheritdoc */ protected function setUp() { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryName = 'directory1'; - $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); - /** @var \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper */ - $imagesHelper = $objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); - $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - $this->fullDirectoryPath = $imagesHelper->getStorageRoot() . DIRECTORY_SEPARATOR . $directoryName; - $this->mediaDirectory->create($this->mediaDirectory->getRelativePath($this->fullDirectoryPath)); - $this->model = $objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\Upload::class); + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->filesystem = $this->objectManager->get(\Magento\Framework\Filesystem::class); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $this->model = $this->objectManager->get(\Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\Upload::class); $fixtureDir = realpath(__DIR__ . '/../../../../../Catalog/_files'); - $tmpFile = __DIR__ . DIRECTORY_SEPARATOR . $this->fileName; + $tmpFile = $this->filesystem->getDirectoryRead(DirectoryList::PUB)->getAbsolutePath() . $this->fileName; copy($fixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFile); $_FILES = [ 'image' => [ @@ -66,21 +66,47 @@ protected function setUp() * located under WYSIWYG media. * * @return void + * @magentoAppIsolation enabled */ public function testExecute() { + $directoryName = 'directory1'; + /** @var \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper */ + $imagesHelper = $this->objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class); + $fullDirectoryPath = $imagesHelper->getStorageRoot() . DIRECTORY_SEPARATOR . $directoryName; + $this->mediaDirectory->create($this->mediaDirectory->getRelativePath($fullDirectoryPath)); + $this->model->getRequest()->setParams(['type' => 'image/png']); - $this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath); + $this->model->getStorage()->getSession()->setCurrentPath($fullDirectoryPath); $this->model->execute(); $this->assertTrue( $this->mediaDirectory->isExist( $this->mediaDirectory->getRelativePath( - $this->fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName + $fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName ) ) ); } + /** + * Execute method with correct directory path and file name to check that file can be uploaded to the directory + * located under linked folder. + * + * @return void + * @magentoDataFixture Magento/Cms/_files/linked_media.php + */ + public function testExecuteWithLinkedMedia() + { + $directoryName = 'linked_media'; + $fullDirectoryPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB) + ->getAbsolutePath() . DIRECTORY_SEPARATOR . $directoryName; + $wysiwygDir = $this->mediaDirectory->getAbsolutePath() . '/wysiwyg'; + $this->model->getRequest()->setParams(['type' => 'image/png']); + $this->model->getStorage()->getSession()->setCurrentPath($wysiwygDir); + $this->model->execute(); + $this->assertTrue(is_file($fullDirectoryPath . DIRECTORY_SEPARATOR . $this->fileName)); + } + /** * @inheritdoc */ diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media.php b/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media.php new file mode 100644 index 0000000000000..03db65db53e9b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media.php @@ -0,0 +1,22 @@ +get(\Magento\Framework\Filesystem::class); +$fullDirectoryPath = $filesystem->getDirectoryRead(Magento\Framework\App\Filesystem\DirectoryList::PUB) + ->getAbsolutePath() . $directoryName; +$mediaDirectory = $filesystem->getDirectoryWrite(Magento\Framework\App\Filesystem\DirectoryList::MEDIA); + +$wysiwygDir = $mediaDirectory->getAbsolutePath() . 'wysiwyg'; +$mediaDirectory->delete($wysiwygDir); +if (!is_dir($fullDirectoryPath)) { + mkdir($fullDirectoryPath); +} +if (is_dir($fullDirectoryPath) && !is_dir($wysiwygDir)) { + symlink($fullDirectoryPath, $wysiwygDir); +} diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media_rollback.php b/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media_rollback.php new file mode 100644 index 0000000000000..856e51ca76ba5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Cms/_files/linked_media_rollback.php @@ -0,0 +1,20 @@ +get(\Magento\Framework\Filesystem::class); +$pubDir = $filesystem->getDirectoryWrite(Magento\Framework\App\Filesystem\DirectoryList::PUB); +$fullDirectoryPath = $pubDir->getAbsolutePath() . DIRECTORY_SEPARATOR . $directoryName; +$mediaDirectory = $filesystem->getDirectoryWrite(Magento\Framework\App\Filesystem\DirectoryList::MEDIA); +$wysiwygDir = $mediaDirectory->getAbsolutePath() . 'wysiwyg'; +if (is_link($wysiwygDir)) { + unlink($wysiwygDir); +} +if (is_dir($fullDirectoryPath)) { + $pubDir->delete($directoryName); +} diff --git a/lib/internal/Magento/Framework/App/Filesystem/DirectoryResolver.php b/lib/internal/Magento/Framework/App/Filesystem/DirectoryResolver.php index 4b62476ae8445..ed044afebd3df 100644 --- a/lib/internal/Magento/Framework/App/Filesystem/DirectoryResolver.php +++ b/lib/internal/Magento/Framework/App/Filesystem/DirectoryResolver.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\App\Filesystem; +use Magento\Framework\Filesystem; + /** * Magento directories resolver. */ @@ -15,12 +17,19 @@ class DirectoryResolver */ private $directoryList; + /** + * @var \Magento\Framework\Filesystem + */ + private $filesystem; + /** * @param DirectoryList $directoryList + * @param Filesystem $filesystem */ - public function __construct(DirectoryList $directoryList) + public function __construct(DirectoryList $directoryList, Filesystem $filesystem) { $this->directoryList = $directoryList; + $this->filesystem = $filesystem; } /** @@ -38,7 +47,8 @@ public function __construct(DirectoryList $directoryList) */ public function validatePath($path, $directoryConfig = DirectoryList::MEDIA) { - $realPath = realpath($path); + $directory = $this->filesystem->getDirectoryWrite($directoryConfig); + $realPath = $directory->getDriver()->getRealPathSafety($path); $root = $this->directoryList->getPath($directoryConfig); return strpos($realPath, $root) === 0; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryResolverTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryResolverTest.php new file mode 100644 index 0000000000000..79c0a95495bd7 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryResolverTest.php @@ -0,0 +1,82 @@ +directoryList = $this->getMockBuilder(\Magento\Framework\App\Filesystem\DirectoryList::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->directoryResolver = new \Magento\Framework\App\Filesystem\DirectoryResolver( + $this->directoryList, + $this->filesystem + ); + } + + /** + * @dataProvider validatePathDataProvider + * @param string $path + * @param bool $expectedResult + */ + public function testValidatePath($path, $expectedResult) + { + $rootPath = '/path/root'; + $directoryConfig = 'directory_config'; + $directory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) + ->setMethods(['getDriver']) + ->getMockForAbstractClass(); + $driver = $this->getMockBuilder(\Magento\Framework\Filesystem\DriverInterface::class) + ->setMethods(['getRealPathSafety']) + ->getMockForAbstractClass(); + $directory->expects($this->atLeastOnce())->method('getDriver')->willReturn($driver); + $driver->expects($this->atLeastOnce())->method('getRealPathSafety')->with($path) + ->willReturnArgument(0); + $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->with($directoryConfig) + ->willReturn($directory); + $this->directoryList->expects($this->atLeastOnce())->method('getPath')->with($directoryConfig) + ->willReturn($rootPath); + $this->assertEquals($expectedResult, $this->directoryResolver->validatePath($path, $directoryConfig)); + } + + /** + * @return array + */ + public function validatePathDataProvider() + { + return [ + ['/path/root/for/validation', true], + ['/path/invalid/for/validation', false] + ]; + } +}