@@ -89,6 +89,10 @@ class OrderTest extends \PHPUnit_Framework_TestCase
89
89
*/
90
90
protected $ relationCompositeMock ;
91
91
92
+ /**
93
+ * @var \Magento\Framework\Model\Resource\Db\ObjectRelationProcessor|\PHPUnit_Framework_MockObject_MockObject
94
+ */
95
+ protected $ objectRelationProcessorMock ;
92
96
/**
93
97
* Mock class dependencies
94
98
*/
@@ -106,10 +110,16 @@ public function setUp()
106
110
'' ,
107
111
false
108
112
);
109
- $ this ->storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , ['__wakeup ' ], [], '' , false );
110
- $ this ->storeGroupMock = $ this ->getMock ('Magento\Store\Model\Group ' , ['__wakeup ' ], [], '' , false );
111
- $ this ->websiteMock = $ this ->getMock ('Magento\Sales\Model\Website ' , ['__wakeup ' ], [], '' , false );
112
- $ this ->customerMock = $ this ->getMock ('Magento\Customer\Model\Customer ' , ['__wakeup ' ], [], '' , false );
113
+ $ this ->storeMock = $ this ->getMock (
114
+ 'Magento\Store\Model\Store ' ,
115
+ [],
116
+ [],
117
+ '' ,
118
+ false
119
+ );
120
+ $ this ->storeGroupMock = $ this ->getMock ('Magento\Store\Model\Group ' , [], [], '' , false );
121
+ $ this ->websiteMock = $ this ->getMock ('Magento\Sales\Model\Website ' , [], [], '' , false );
122
+ $ this ->customerMock = $ this ->getMock ('Magento\Customer\Model\Customer ' , [], [], '' , false );
113
123
$ this ->orderItemCollectionMock = $ this ->getMock (
114
124
'Magento\Sales\Model\Resource\Order\Item\Collection ' ,
115
125
[],
@@ -154,7 +164,7 @@ public function setUp()
154
164
'' ,
155
165
false
156
166
);
157
- $ this ->salesSequenceMock = $ this ->getMock ('Magento\SalesSequence\Sequence ' , [], [], '' , false );
167
+ $ this ->salesSequenceMock = $ this ->getMock ('Magento\SalesSequence\Model\ Sequence ' , [], [], '' , false );
158
168
$ this ->entitySnapshotMock = $ this ->getMock (
159
169
'Magento\Sales\Model\Resource\EntitySnapshot ' ,
160
170
[],
@@ -169,8 +179,18 @@ public function setUp()
169
179
'' ,
170
180
false
171
181
);
182
+ $ this ->objectRelationProcessorMock = $ this ->getMock (
183
+ 'Magento\Framework\Model\Resource\Db\ObjectRelationProcessor ' ,
184
+ [],
185
+ [],
186
+ '' ,
187
+ false
188
+ );
172
189
$ contextMock = $ this ->getMock ('\Magento\Framework\Model\Resource\Db\Context ' , [], [], '' , false );
173
190
$ contextMock ->expects ($ this ->once ())->method ('getResources ' )->willReturn ($ this ->resourceMock );
191
+ $ contextMock ->expects ($ this ->once ())
192
+ ->method ('getObjectRelationProcessor ' )
193
+ ->willReturn ($ this ->objectRelationProcessorMock );
174
194
175
195
$ this ->resource = new Order (
176
196
$ contextMock ,
@@ -184,6 +204,51 @@ public function setUp()
184
204
185
205
public function testSave ()
186
206
{
207
+
208
+ $ this ->orderMock ->expects ($ this ->once ())
209
+ ->method ('validateBeforeSave ' )
210
+ ->willReturnSelf ();
211
+ $ this ->orderMock ->expects ($ this ->once ())
212
+ ->method ('beforeSave ' )
213
+ ->willReturnSelf ();
214
+ $ this ->orderMock ->expects ($ this ->once ())
215
+ ->method ('isSaveAllowed ' )
216
+ ->willReturn (true );
217
+ $ this ->orderMock ->expects ($ this ->once ())
218
+ ->method ('getEntityType ' )
219
+ ->willReturn ('order ' );
220
+ $ this ->orderMock ->expects ($ this ->once ())
221
+ ->method ('getStore ' )
222
+ ->willReturn ($ this ->storeMock );
223
+ $ this ->storeMock ->expects ($ this ->once ())
224
+ ->method ('getGroup ' )
225
+ ->willReturn ($ this ->storeGroupMock );
226
+ $ this ->storeGroupMock ->expects ($ this ->once ())
227
+ ->method ('getDefaultStoreId ' )
228
+ ->willReturn (1 );
229
+ $ this ->salesSequenceManagerMock ->expects ($ this ->once ())
230
+ ->method ('getSequence ' )
231
+ ->with ('order ' , 1 )
232
+ ->willReturn ($ this ->salesSequenceMock );
233
+ $ this ->salesSequenceMock ->expects ($ this ->once ())
234
+ ->method ('getNextValue ' )
235
+ ->willReturn ('10000001 ' );
236
+ $ this ->orderMock ->expects ($ this ->once ())
237
+ ->method ('setIncrementId ' )
238
+ ->with ('10000001 ' )
239
+ ->willReturnSelf ();
240
+ $ this ->orderMock ->expects ($ this ->once ())
241
+ ->method ('getIncrementId ' )
242
+ ->willReturn (null );
243
+ $ this ->orderMock ->expects ($ this ->once ())
244
+ ->method ('getData ' )
245
+ ->willReturn (['increment_id ' => '10000001 ' ]);
246
+ $ this ->objectRelationProcessorMock ->expects ($ this ->once ())
247
+ ->method ('validateDataIntegrity ' )
248
+ ->with (null , ['increment_id ' => '10000001 ' ]);
249
+ $ this ->relationCompositeMock ->expects ($ this ->once ())
250
+ ->method ('processRelations ' )
251
+ ->with ($ this ->orderMock );
187
252
$ this ->resourceMock ->expects ($ this ->any ())
188
253
->method ('getConnection ' )
189
254
->willReturn ($ this ->adapterMock );
0 commit comments