public function testMediaBackup() { $this->setupCodeBackupRollback(); $this->filesystem->expects($this->once())->method('create'); $this->file->expects($this->once())->method('isExists')->with($this->path . '/backups')->willReturn(false); $this->file->expects($this->once())->method('createDirectory')->with($this->path . '/backups'); $this->model->codeBackup(time(), Factory::TYPE_MEDIA); }
/** * Takes backup for code, media or DB * * @return JsonModel */ public function createAction() { $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); try { $time = time(); $backupFiles = []; if (isset($params['options']['code']) && $params['options']['code']) { $backupFiles[] = $this->backupHandler->codeBackup($time); } if (isset($params['options']['media']) && $params['options']['media']) { $backupFiles[] = $this->backupHandler->codeBackup($time, Factory::TYPE_MEDIA); } if (isset($params['options']['db']) && $params['options']['db']) { $backupFiles[] = $this->backupHandler->dbBackup($time); } return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, 'files' => $backupFiles]); } catch (\Exception $e) { return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'error' => $e->getMessage()]); } }