Example #1
0
 /**
  * Delete file
  *
  * @param string $file
  * @return \Magento\Theme\Model\Wysiwyg\Storage
  */
 public function deleteFile($file)
 {
     $file = $this->urlDecoder->decode($file);
     $path = $this->mediaWriteDirectory->getRelativePath($this->_helper->getCurrentPath());
     $filePath = $this->mediaWriteDirectory->getRelativePath($path . '/' . $file);
     $thumbnailPath = $this->_helper->getThumbnailDirectory($filePath) . '/' . $file;
     if (0 === strpos($filePath, $path) && 0 === strpos($filePath, $this->_helper->getStorageRoot())) {
         $this->mediaWriteDirectory->delete($filePath);
         $this->mediaWriteDirectory->delete($thumbnailPath);
     }
     return $this;
 }
Example #2
0
 /**
  * @covers \Magento\Theme\Model\Wysiwyg\Storage::_createThumbnail
  */
 public function testCreateThumbnail()
 {
     $image = 'some_image.jpg';
     $imagePath = realpath(__DIR__) . "/_files/theme/image/{$image}";
     $tmpImagePath = $this->_copyFileToTmpCustomizationPath($imagePath);
     $relativePath = $this->directoryTmp->getRelativePath($tmpImagePath);
     $method = $this->_getMethod('_createThumbnail');
     $result = $method->invokeArgs($this->_storageModel, array($relativePath));
     $expectedResult = $this->directoryTmp->getRelativePath($this->_helperStorage->getThumbnailDirectory($tmpImagePath) . '/' . $image);
     $this->assertEquals($expectedResult, $result);
     $this->assertFileExists($this->directoryTmp->getAbsolutePath($result));
 }
Example #3
0
 public function testGetThumbnailDirectory()
 {
     $imagePath = implode('/', ['root', 'image', 'image_name.jpg']);
     $thumbnailDir = implode('/', ['root', 'image', \Magento\Theme\Model\Wysiwyg\Storage::THUMBNAIL_DIRECTORY]);
     $this->assertEquals($thumbnailDir, $this->helper->getThumbnailDirectory($imagePath));
 }