Пример #1
0
 /**
  * @param int $storage
  * @param int $callNum
  * @dataProvider updateFileDataProvider
  */
 public function testRenameFile($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('renameFile')->with('oldName', 'newName');
     $this->helper->renameFile('media-dir/oldName', 'media-dir/newName');
 }
Пример #2
0
 /**
  * Move image from temporary directory to normal
  *
  * @param string $file
  * @return string
  */
 protected function moveImageFromTmp($file)
 {
     $file = $this->getFilenameFromTmp($file);
     $destinationFile = $this->getUniqueFileName($file);
     if ($this->fileStorageDb->checkDbUsage()) {
         $this->fileStorageDb->renameFile($this->mediaConfig->getTmpMediaShortUrl($file), $this->mediaConfig->getMediaShortUrl($destinationFile));
         $this->mediaDirectory->delete($this->mediaConfig->getTmpMediaPath($file));
         $this->mediaDirectory->delete($this->mediaConfig->getMediaPath($destinationFile));
     } else {
         $this->mediaDirectory->renameFile($this->mediaConfig->getTmpMediaPath($file), $this->mediaConfig->getMediaPath($destinationFile));
     }
     return str_replace('\\', '/', $destinationFile);
 }