Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #10032 - Download back-up .tgz always takes the latest that's created (2.1-develop) #11596

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions app/code/Magento/Backup/Model/BackupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,16 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
*/
public function create($timestamp, $type)
{
$backupId = $timestamp . '_' . $type;
$fsCollection = $this->_objectManager->get('Magento\Backup\Model\Fs\Collection');
$backupInstance = $this->_objectManager->get('Magento\Backup\Model\Backup');

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;
}
}
Expand Down
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