public function testCheckActionWithError()
 {
     $this->directoryList->expects($this->once())->method('getPath')->willReturn(__DIR__);
     $this->filesystem->expects($this->once())->method('validateAvailableDiscSpace')->will($this->throwException(new \Exception("Test error message")));
     $jsonModel = $this->controller->checkAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('responseType', $variables);
     $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']);
     $this->assertArrayHasKey('error', $variables);
     $this->assertEquals("Test error message", $variables['error']);
 }
 private function setupCodeBackupRollback()
 {
     $this->filesystem->expects($this->once())->method('addIgnorePaths');
     $this->filesystem->expects($this->once())->method('setBackupsDir');
     $this->filesystem->expects($this->once())->method('setBackupExtension');
     $this->filesystem->expects($this->once())->method('setTime');
     $this->filesystem->expects($this->once())->method('getBackupFilename')->willReturn('RollbackFile_A.tgz');
     $this->filesystem->expects($this->atLeastOnce())->method('getBackupPath')->willReturn('pathToFile/12345_filesystem_code.tgz');
     $this->log->expects($this->once())->method('logSuccess');
 }
 /**
  * Checks disk space availability
  *
  * @return JsonModel
  */
 public function checkAction()
 {
     $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $backupDir = $this->directoryList->getPath(DirectoryList::VAR_DIR) . '/' . BackupRollback::DEFAULT_BACKUP_DIRECTORY;
     try {
         $totalSize = 0;
         if (isset($params['options']['code']) && $params['options']['code']) {
             $totalSize += $this->backupHandler->getFSDiskSpace();
         }
         if (isset($params['options']['media']) && $params['options']['media']) {
             $totalSize += $this->backupHandler->getFSDiskSpace(Factory::TYPE_MEDIA);
         }
         if (isset($params['options']['db']) && $params['options']['db']) {
             $totalSize += $this->backupHandler->getDBDiskSpace();
         }
         $this->fileSystem->validateAvailableDiscSpace($backupDir, $totalSize);
         return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, 'size' => true]);
     } catch (\Exception $e) {
         return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'error' => $e->getMessage()]);
     }
 }
Ejemplo n.º 4
0
 /**
  * Implementation Create Backup functionality for Snapshot
  *
  * @throws \Exception
  * @return bool
  */
 public function create()
 {
     $this->_getDbBackupManager()->create();
     try {
         $result = parent::create();
     } catch (\Exception $e) {
         $this->_removeDbBackup();
         throw $e;
     }
     $this->_lastOperationSucceed = false;
     $this->_removeDbBackup();
     $this->_lastOperationSucceed = true;
     return $result;
 }