Skip to content

Commit 949e445

Browse files
author
Pieter Cappelle
committed
Fix issue 10032
1 parent 13d3888 commit 949e445

File tree

2 files changed

+30
-47
lines changed

2 files changed

+30
-47
lines changed

app/code/Magento/Backup/Model/BackupFactory.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,16 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
3535
*/
3636
public function create($timestamp, $type)
3737
{
38-
$backupId = $timestamp . '_' . $type;
3938
$fsCollection = $this->_objectManager->get('Magento\Backup\Model\Fs\Collection');
4039
$backupInstance = $this->_objectManager->get('Magento\Backup\Model\Backup');
40+
4141
foreach ($fsCollection as $backup) {
42-
if ($backup->getId() == $backupId) {
43-
$backupInstance->setType(
44-
$backup->getType()
45-
)->setTime(
46-
$backup->getTime()
47-
)->setName(
48-
$backup->getName()
49-
)->setPath(
50-
$backup->getPath()
51-
);
42+
if ($backup->getTime() === (int) $timestamp && $backup->getType() === $type) {
43+
$backupInstance->setData(['id' => $backup->getId()])
44+
->setType($backup->getType())
45+
->setTime($backup->getTime())
46+
->setName($backup->getName())
47+
->setPath($backup->getPath());
5248
break;
5349
}
5450
}

app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,42 +77,29 @@ protected function setUp()
7777

7878
public function testCreate()
7979
{
80-
$this->_backupModel->expects(
81-
$this->once()
82-
)->method(
83-
'setType'
84-
)->with(
85-
$this->_data['type']
86-
)->will(
87-
$this->returnSelf()
88-
);
89-
$this->_backupModel->expects(
90-
$this->once()
91-
)->method(
92-
'setTime'
93-
)->with(
94-
$this->_data['time']
95-
)->will(
96-
$this->returnSelf()
97-
);
98-
$this->_backupModel->expects(
99-
$this->once()
100-
)->method(
101-
'setName'
102-
)->with(
103-
$this->_data['name']
104-
)->will(
105-
$this->returnSelf()
106-
);
107-
$this->_backupModel->expects(
108-
$this->once()
109-
)->method(
110-
'setPath'
111-
)->with(
112-
$this->_data['path']
113-
)->will(
114-
$this->returnSelf()
115-
);
80+
$this->_backupModel->expects($this->once())
81+
->method('setType')
82+
->with($this->_data['type'])
83+
->will($this->returnSelf());
84+
85+
$this->_backupModel->expects($this->once())
86+
->method('setTime')
87+
->with($this->_data['time'])
88+
->will($this->returnSelf());
89+
90+
$this->_backupModel->expects($this->once())
91+
->method('setName')
92+
->with($this->_data['name'])
93+
->will($this->returnSelf());
94+
95+
$this->_backupModel->expects($this->once())
96+
->method('setPath')
97+
->with($this->_data['path'])
98+
->will($this->returnSelf());
99+
100+
$this->_backupModel->expects($this->once())
101+
->method('setData')
102+
->will($this->returnSelf());
116103

117104
$this->_instance->create('1385661590', 'snapshot');
118105
}

0 commit comments

Comments
 (0)