File tree 2 files changed +31
-47
lines changed
2 files changed +31
-47
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,20 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
38
38
*/
39
39
public function create ($ timestamp , $ type )
40
40
{
41
- $ backupId = $ timestamp . '_ ' . $ type ;
42
41
$ fsCollection = $ this ->_objectManager ->get (\Magento \Backup \Model \Fs \Collection::class);
43
42
$ backupInstance = $ this ->_objectManager ->get (\Magento \Backup \Model \Backup::class);
43
+
44
44
foreach ($ fsCollection as $ backup ) {
45
- if ($ backup ->getId () == $ backupId ) {
46
- $ backupInstance ->setType (
47
- $ backup ->getType ()
48
- )->setTime (
49
- $ backup ->getTime ()
50
- )->setName (
51
- $ backup ->getName ()
52
- )->setPath (
53
- $ backup ->getPath ()
54
- );
45
+ if ($ backup ->getTime () === (int ) $ timestamp && $ backup ->getType () === $ type ) {
46
+ $ backupInstance ->setData (['id ' => $ backup ->getId ()])
47
+ ->setType ($ backup ->getType ())
48
+ ->setTime ($ backup ->getTime ())
49
+ ->setName ($ backup ->getName ())
50
+ ->setPath ($ backup ->getPath ());
55
51
break ;
56
52
}
57
53
}
54
+
58
55
return $ backupInstance ;
59
56
}
60
57
}
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