public function setUp() { $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); $this->log = $this->getMock('Magento\Framework\Setup\LoggerInterface', [], [], '', false); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->path = realpath(__DIR__); $this->directoryList->expects($this->any()) ->method('getRoot') ->willReturn($this->path); $this->directoryList->expects($this->any()) ->method('getPath') ->willReturn($this->path); $this->file = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); $this->filesystem = $this->getMock('Magento\Framework\Backup\Filesystem', [], [], '', false); $this->database = $this->getMock('Magento\Framework\Backup\Db', [], [], '', false); $this->helper = $this->getMock('Magento\Framework\Backup\Filesystem\Helper', [], [], '', false); $this->helper->expects($this->any()) ->method('getInfo') ->willReturn(['writable' => true, 'size' => 100]); $configLoader = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false); $configLoader->expects($this->any()) ->method('load') ->willReturn([]); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ ['Magento\Framework\App\State', $this->getMock('Magento\Framework\App\State', [], [], '', false)], ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], ])); $this->objectManager->expects($this->any()) ->method('create') ->will($this->returnValueMap([ ['Magento\Framework\Backup\Filesystem\Helper', [], $this->helper], ['Magento\Framework\Backup\Filesystem', [], $this->filesystem], ['Magento\Framework\Backup\Db', [], $this->database], ])); $this->model = new BackupRollback( $this->objectManager, $this->log, $this->directoryList, $this->file, $this->helper ); }
/** * Get disk availability for filesystem backup * * @param string $type * @return int * @throws LocalizedException */ public function getFSDiskSpace($type = Factory::TYPE_FILESYSTEM) { $filesystemSize = 0; if ($type === Factory::TYPE_FILESYSTEM) { $ignorePaths = $this->getCodeBackupIgnorePaths(); } elseif ($type === Factory::TYPE_MEDIA) { $ignorePaths = $this->getMediaBackupIgnorePaths(); } else { throw new LocalizedException(new Phrase("This backup type '{$type}' is not supported.")); } $filesInfo = $this->fsHelper->getInfo($this->directoryList->getRoot(), Helper::INFO_SIZE, $ignorePaths); if ($filesInfo['size']) { $filesystemSize = $filesInfo['size']; } return $filesystemSize; }