Example #1
0
 public function testCreateInvalid()
 {
     $this->_backupModel->expects($this->never())->method('setType');
     $this->_backupModel->expects($this->never())->method('setTime');
     $this->_backupModel->expects($this->never())->method('setName');
     $this->_backupModel->expects($this->never())->method('setPath');
     $this->_instance->create('451094400', 'snapshot');
 }
 /**
  * Get backup-specific data from model for each row
  *
  * @param string $filename
  * @return array
  */
 protected function _generateRow($filename)
 {
     $row = parent::_generateRow($filename);
     foreach ($this->_backup->load($row['basename'], $this->_varDirectory->getAbsolutePath($this->_path))->getData() as $key => $value) {
         $row[$key] = $value;
     }
     $row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
     $row['id'] = $row['time'] . '_' . $row['type'];
     return $row;
 }
Example #3
0
 /**
  * Get backup-specific data from model for each row
  *
  * @param string $filename
  * @return array
  */
 protected function _generateRow($filename)
 {
     $row = parent::_generateRow($filename);
     foreach ($this->_backup->load($row['basename'], $this->_varDirectory->getAbsolutePath($this->_path))->getData() as $key => $value) {
         $row[$key] = $value;
     }
     $row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
     if (isset($row['display_name']) && $row['display_name'] == '') {
         $row['display_name'] = 'WebSetupWizard';
     }
     $row['id'] = $row['time'] . '_' . $row['type'] . (isset($row['display_name']) ? $row['display_name'] : '');
     return $row;
 }
Example #4
0
 /**
  * @covers \Magento\Backup\Model\Backup::output
  * @param bool $isFile
  * @param string $result
  * @dataProvider outputDataProvider
  */
 public function testOutput($isFile, $result)
 {
     $path = '/path/to';
     $time = 1;
     $name = 'test';
     $type = 'db';
     $extension = 'sql';
     $relativePath = '/path/to/1_db_test.sql';
     $contents = 'test_result';
     $this->directoryMock->expects($this->atLeastOnce())->method('isFile')->with($relativePath)->willReturn($isFile);
     $this->directoryMock->expects($this->any())->method('getRelativePath')->with($relativePath)->willReturn($relativePath);
     $this->directoryMock->expects($this->any())->method('readFile')->with($relativePath)->willReturn($contents);
     $this->dataHelperMock->expects($this->any())->method('getExtensionByType')->with($type)->willReturn($extension);
     $this->backupModel->setPath($path);
     $this->backupModel->setName($name);
     $this->backupModel->setTime($time);
     $this->assertEquals($result, $this->backupModel->output());
 }
Example #5
0
 /**
  * @covers \Magento\Backup\Controller\Adminhtml\Index\Download::execute
  * @param int $time
  * @param bool $exists
  * @param int $existsCount
  * @dataProvider executeBackupNotFoundDataProvider
  */
 public function testExecuteBackupNotFound($time, $exists, $existsCount)
 {
     $type = 'db';
     $this->backupModelMock->expects($this->atLeastOnce())->method('getTime')->willReturn($time);
     $this->backupModelMock->expects($this->exactly($existsCount))->method('exists')->willReturn($exists);
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['time', null, $time], ['type', null, $type]]);
     $this->backupModelFactoryMock->expects($this->once())->method('create')->with($time, $type)->willReturn($this->backupModelMock);
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('backup/*');
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->assertSame($this->resultRedirectMock, $this->downloadController->execute());
 }
Example #6
0
 /**
  * Generate backup download name
  *
  * @param \Magento\Backup\Model\Backup $backup
  * @return string
  */
 public function generateBackupDownloadName(\Magento\Backup\Model\Backup $backup)
 {
     $additionalExtension = $backup->getType() == \Magento\Framework\Backup\Factory::TYPE_DB ? '.sql' : '';
     return $backup->getTime() . '_' . $backup->getType() . '_' . $backup->getName() . $additionalExtension . '.' . $this->getExtensionByType($backup->getType());
 }