Exemplo n.º 1
0
 public function testExecuteDBBackup()
 {
     $input = ['module' => ['Magento_A', 'Magento_B'], '--backup-db' => true];
     $this->setUpExecute($input);
     $this->backupRollback->expects($this->once())
         ->method('dbBackup')
         ->willReturn($this->backupRollback);
     $this->tester->execute($input);
 }
 public function testExecuteDBBackup()
 {
     $input = ['module' => ['Magento_A', 'Magento_B'], '--backup-db' => true];
     $this->setUpExecute();
     $this->moduleUninstaller->expects($this->once())->method('uninstallCode')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDb')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDeploymentConfig')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->backupRollback->expects($this->once())->method('dbBackup')->willReturn($this->backupRollback);
     $this->tester->execute($input);
 }
Exemplo n.º 3
0
 public function testExecuteDBBackup()
 {
     $this->deploymentConfig->expects($this->once())
         ->method('isAvailable')
         ->will($this->returnValue(true));
     $this->backupRollback->expects($this->once())
         ->method('dbBackup')
         ->willReturn($this->backupRollback);
     $this->tester->execute(['--db' => true]);
 }
Exemplo n.º 4
0
 public function testDbRollback()
 {
     $this->setupDbBackupRollback();
     $this->database->expects($this->once())->method('rollback');
     $this->file->expects($this->once())
         ->method('isExists')
         ->with($this->path . '/backups/12345_db.gz')
         ->willReturn(true);
     $this->model->dbRollback('12345_db.gz');
 }
 public function testCreateAction()
 {
     $this->backupRollback->expects($this->once())->method('dbBackup')->willReturn('backup/path/');
     $jsonModel = $this->controller->createAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('responseType', $variables);
     $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']);
     $this->assertArrayHasKey('files', $variables);
     $this->assertEquals(['backup/path/'], $variables['files']);
 }
 /**
  * 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()]);
     }
 }
 public function testGetDBDiskSpace()
 {
     $this->database->expects($this->once())->method('getDBSize')->willReturn(100);
     $size = $this->model->getDBDiskSpace();
     $this->assertEquals(100, $size);
 }
Exemplo n.º 8
0
 public function testExecute()
 {
     $this->backupRollbackFactory->expects($this->once())->method('create')->willReturn($this->backupRollback);
     $this->backupRollback->expects($this->once())->method('dbRollback');
     $this->jobDbRollback->execute();
 }