8
8
9
9
use Magento \Quote \Model \Quote \Address ;
10
10
11
+ /**
12
+ * Unit tests coverage for @see \Magento\Framework\DataObject\Copy
13
+ */
11
14
class CopyTest extends \PHPUnit \Framework \TestCase
12
15
{
13
16
/**
@@ -91,7 +94,7 @@ public function testCopyFieldsetToTargetWhenFieldExists()
91
94
$ data = [
92
95
'target ' => new \Magento \Framework \DataObject ([$ this ->targetMock ]),
93
96
'source ' => $ this ->sourceMock ,
94
- 'root ' => 'global ' ,
97
+ 'root ' => 'global ' ,
95
98
];
96
99
$ this ->eventManagerMock ->expects ($ this ->once ())->method ('dispatch ' )->with ($ eventName , $ data );
97
100
$ this ->assertEquals (
@@ -124,7 +127,7 @@ public function testCopyFieldsetToTargetWhenTargetNotArray()
124
127
$ data = [
125
128
'target ' => $ this ->targetMock ,
126
129
'source ' => $ this ->sourceMock ,
127
- 'root ' => 'global ' ,
130
+ 'root ' => 'global ' ,
128
131
];
129
132
$ this ->eventManagerMock ->expects ($ this ->once ())->method ('dispatch ' )->with ($ eventName , $ data );
130
133
$ this ->assertEquals (
@@ -160,7 +163,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsArray()
160
163
$ data = [
161
164
'target ' => new \Magento \Framework \DataObject ($ newTarget ),
162
165
'source ' => $ this ->sourceMock ,
163
- 'root ' => 'global ' ,
166
+ 'root ' => 'global ' ,
164
167
];
165
168
$ this ->eventManagerMock ->expects ($ this ->once ())->method ('dispatch ' )->with ($ eventName , $ data );
166
169
$ this ->assertEquals (
@@ -178,14 +181,21 @@ public function testGetCopyFieldsetToTargetWhenTargetIsExtensibleDataInterface()
178
181
->with ('fieldset ' , 'global ' )
179
182
->will ($ this ->returnValue ($ fields ));
180
183
181
- $ sourceMock = $ this ->createPartialMock (\Magento \Framework \Api \ExtensibleDataInterface::class, [
182
- 'getExtensionAttributes ' , 'getCode '
183
- ]);
184
- $ targetMock = $ this ->createPartialMock (\Magento \Framework \Api \ExtensibleDataInterface::class, [
184
+ $ sourceMock = $ this ->createPartialMock (
185
+ \Magento \Framework \Api \ExtensibleDataInterface::class,
186
+ [
187
+ 'getExtensionAttributes ' ,
188
+ 'getCode '
189
+ ]
190
+ );
191
+ $ targetMock = $ this ->createPartialMock (
192
+ \Magento \Framework \Api \ExtensibleDataInterface::class,
193
+ [
185
194
'getExtensionAttributes ' ,
186
195
'setCode ' ,
187
196
'setExtensionAttributes '
188
- ]);
197
+ ]
198
+ );
189
199
190
200
$ sourceMock
191
201
->expects ($ this ->any ())
@@ -224,12 +234,18 @@ public function testGetCopyFieldsetToTargetWhenTargetIsAbstractSimpleObject()
224
234
->with ('fieldset ' , 'global ' )
225
235
->will ($ this ->returnValue ($ fields ));
226
236
227
- $ sourceMock = $ this ->createPartialMock (\Magento \Framework \Api \AbstractSimpleObject::class, [
237
+ $ sourceMock = $ this ->createPartialMock (
238
+ \Magento \Framework \Api \AbstractSimpleObject::class,
239
+ [
228
240
'__toArray '
229
- ]);
230
- $ targetMock = $ this ->createPartialMock (\Magento \Framework \Api \AbstractSimpleObject::class, [
241
+ ]
242
+ );
243
+ $ targetMock = $ this ->createPartialMock (
244
+ \Magento \Framework \Api \AbstractSimpleObject::class,
245
+ [
231
246
'setData '
232
- ]);
247
+ ]
248
+ );
233
249
234
250
$ sourceMock
235
251
->expects ($ this ->once ())
@@ -312,15 +328,21 @@ public function testGetExtensionAttributeForDataObjectChild()
312
328
->with ('fieldset ' , 'global ' )
313
329
->will ($ this ->returnValue ($ fields ));
314
330
315
- $ sourceMock = $ this ->createPartialMock (Address::class, [
316
- 'getExtensionAttributes ' , 'getCode '
317
- ]);
331
+ $ sourceMock = $ this ->createPartialMock (
332
+ Address::class,
333
+ [
334
+ 'getExtensionAttributes ' ,
335
+ 'getCode '
336
+ ]
337
+ );
318
338
$ targetMock = $ this ->createPartialMock (
319
- Address::class, [
320
- 'getExtensionAttributes ' ,
321
- 'setCode ' ,
322
- 'setExtensionAttributes '
323
- ]);
339
+ Address::class,
340
+ [
341
+ 'getExtensionAttributes ' ,
342
+ 'setCode ' ,
343
+ 'setExtensionAttributes '
344
+ ]
345
+ );
324
346
325
347
$ sourceMock
326
348
->expects ($ this ->any ())
@@ -349,7 +371,7 @@ public function testGetExtensionAttributeForDataObjectChild()
349
371
$ this ->assertEquals ($ result , $ targetMock );
350
372
}
351
373
352
- public function testGetDataObjectFieldFromExtensbielEntity ()
374
+ public function testGetDataObjectFieldFromExtensibleEntity ()
353
375
{
354
376
$ fields ['code ' ]['aspect ' ] = '* ' ;
355
377
$ this ->fieldsetConfigMock
@@ -358,13 +380,18 @@ public function testGetDataObjectFieldFromExtensbielEntity()
358
380
->with ('fieldset ' , 'global ' )
359
381
->will ($ this ->returnValue ($ fields ));
360
382
361
- $ sourceMock = $ this ->createPartialMock (Address::class, [
362
- 'getExtensionAttributes '
363
- ]);
383
+ $ sourceMock = $ this ->createPartialMock (
384
+ Address::class,
385
+ [
386
+ 'getExtensionAttributes '
387
+ ]
388
+ );
364
389
$ targetMock = $ this ->createPartialMock (
365
- Address::class, [
366
- 'getExtensionAttributes '
367
- ]);
390
+ Address::class,
391
+ [
392
+ 'getExtensionAttributes '
393
+ ]
394
+ );
368
395
369
396
$ sourceMock
370
397
->expects ($ this ->any ())
@@ -378,7 +405,6 @@ public function testGetDataObjectFieldFromExtensbielEntity()
378
405
->method ('getExtensionAttributes ' )
379
406
->willReturn (null );
380
407
381
-
382
408
$ this ->eventManagerMock ->expects ($ this ->once ())->method ('dispatch ' );
383
409
$ result = $ this ->copy ->copyFieldsetToTarget ('fieldset ' , 'aspect ' , $ sourceMock , $ targetMock );
384
410
$ this ->assertEquals ($ result , $ targetMock );
0 commit comments