Skip to content

Commit

Permalink
MAGETWO-82710: Fix issue #10032 - Download back-up .tgz always takes …
Browse files Browse the repository at this point in the history
…the latest that's created (2.2-develop) #11595

 - Merge Pull Request #11595 from PieterCappelle/magento2:fix_2_2_issue_10032
 - Merged commits:
   1. c630e4a
  • Loading branch information
dmanners committed Oct 25, 2017
2 parents 08f0056 + c630e4a commit 00e9b6a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 deletions.
19 changes: 8 additions & 11 deletions app/code/Magento/Backup/Model/BackupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,20 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
*/
public function create($timestamp, $type)
{
$backupId = $timestamp . '_' . $type;
$fsCollection = $this->_objectManager->get(\Magento\Backup\Model\Fs\Collection::class);
$backupInstance = $this->_objectManager->get(\Magento\Backup\Model\Backup::class);

foreach ($fsCollection as $backup) {
if ($backup->getId() == $backupId) {
$backupInstance->setType(
$backup->getType()
)->setTime(
$backup->getTime()
)->setName(
$backup->getName()
)->setPath(
$backup->getPath()
);
if ($backup->getTime() === (int) $timestamp && $backup->getType() === $type) {
$backupInstance->setData(['id' => $backup->getId()])
->setType($backup->getType())
->setTime($backup->getTime())
->setName($backup->getName())
->setPath($backup->getPath());
break;
}
}

return $backupInstance;
}
}
59 changes: 23 additions & 36 deletions app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,29 @@ protected function setUp()

public function testCreate()
{
$this->_backupModel->expects(
$this->once()
)->method(
'setType'
)->with(
$this->_data['type']
)->will(
$this->returnSelf()
);
$this->_backupModel->expects(
$this->once()
)->method(
'setTime'
)->with(
$this->_data['time']
)->will(
$this->returnSelf()
);
$this->_backupModel->expects(
$this->once()
)->method(
'setName'
)->with(
$this->_data['name']
)->will(
$this->returnSelf()
);
$this->_backupModel->expects(
$this->once()
)->method(
'setPath'
)->with(
$this->_data['path']
)->will(
$this->returnSelf()
);
$this->_backupModel->expects($this->once())
->method('setType')
->with($this->_data['type'])
->will($this->returnSelf());

$this->_backupModel->expects($this->once())
->method('setTime')
->with($this->_data['time'])
->will($this->returnSelf());

$this->_backupModel->expects($this->once())
->method('setName')
->with($this->_data['name'])
->will($this->returnSelf());

$this->_backupModel->expects($this->once())
->method('setPath')
->with($this->_data['path'])
->will($this->returnSelf());

$this->_backupModel->expects($this->once())
->method('setData')
->will($this->returnSelf());

$this->_instance->create('1385661590', 'snapshot');
}
Expand Down

0 comments on commit 00e9b6a

Please sign in to comment.