File tree 2 files changed +30
-47
lines changed
2 files changed +30
-47
lines changed Original file line number Diff line number Diff line change @@ -35,20 +35,16 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
35
35
*/
36
36
public function create ($ timestamp , $ type )
37
37
{
38
- $ backupId = $ timestamp . '_ ' . $ type ;
39
38
$ fsCollection = $ this ->_objectManager ->get ('Magento\Backup\Model\Fs\Collection ' );
40
39
$ backupInstance = $ this ->_objectManager ->get ('Magento\Backup\Model\Backup ' );
40
+
41
41
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 ());
52
48
break ;
53
49
}
54
50
}
Original file line number Diff line number Diff line change @@ -77,42 +77,29 @@ protected function setUp()
77
77
78
78
public function testCreate ()
79
79
{
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 ());
116
103
117
104
$ this ->_instance ->create ('1385661590 ' , 'snapshot ' );
118
105
}
You can’t perform that action at this time.
0 commit comments