Beispiel #1
0
 /**
  * @param int $storage
  * @param int $callNum
  * @dataProvider updateFileDataProvider
  */
 public function testDeleteFile($storage, $callNum)
 {
     $this->configMock->expects($this->once())->method('getValue')->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default')->will($this->returnValue($storage));
     $dbModelMock = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\Storage\\Database')->disableOriginalConstructor()->getMock();
     $this->dbStorageFactoryMock->expects($this->exactly($callNum))->method('create')->will($this->returnValue($dbModelMock));
     $dbModelMock->expects($this->exactly($callNum))->method('deleteFile')->with('file');
     $this->helper->deleteFile('media-dir/file');
 }
Beispiel #2
0
 /**
  * Delete file (and its thumbnail if exists) from storage
  *
  * @param string $target File path to be deleted
  * @return $this
  */
 public function deleteFile($target)
 {
     $relativePath = $this->_directory->getRelativePath($target);
     if ($this->_directory->isFile($relativePath)) {
         $this->_directory->delete($relativePath);
     }
     $this->_coreFileStorageDb->deleteFile($target);
     $thumb = $this->getThumbnailPath($target, true);
     $relativePathThumb = $this->_directory->getRelativePath($thumb);
     if ($thumb) {
         if ($this->_directory->isFile($relativePathThumb)) {
             $this->_directory->delete($relativePathThumb);
         }
         $this->_coreFileStorageDb->deleteFile($thumb);
     }
     return $this;
 }