@@ -344,25 +344,13 @@ public function testCanUseAttribute()
344
344
345
345
public function testGetUsedProducts ()
346
346
{
347
- $ productCollectionItemData = ['array ' ];
347
+ $ productCollectionItem = $ this ->createMock (\Magento \Catalog \Model \Product::class);
348
+ $ attributeCollection = $ this ->createMock (Collection::class);
349
+ $ product = $ this ->createMock (\Magento \Catalog \Model \Product::class);
350
+ $ productCollection = $ this ->createMock (ProductCollection::class);
348
351
349
- $ productCollectionItem = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
350
- ->disableOriginalConstructor ()
351
- ->getMock ();
352
- $ attributeCollection = $ this ->getMockBuilder (Collection::class)
353
- ->disableOriginalConstructor ()
354
- ->getMock ();
355
- $ product = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
356
- ->disableOriginalConstructor ()
357
- ->getMock ();
358
- $ productCollection = $ this ->getMockBuilder (ProductCollection::class)
359
- ->disableOriginalConstructor ()
360
- ->getMock ();
361
-
362
- $ productCollectionItem ->expects ($ this ->once ())->method ('getData ' )->willReturn ($ productCollectionItemData );
363
352
$ attributeCollection ->expects ($ this ->any ())->method ('setProductFilter ' )->willReturnSelf ();
364
353
$ product ->expects ($ this ->atLeastOnce ())->method ('getStoreId ' )->willReturn (5 );
365
- $ product ->expects ($ this ->once ())->method ('getIdentities ' )->willReturn (['123 ' ]);
366
354
367
355
$ product ->expects ($ this ->exactly (2 ))
368
356
->method ('hasData ' )
@@ -388,59 +376,10 @@ public function testGetUsedProducts()
388
376
$ productCollection ->expects ($ this ->once ())->method ('setStoreId ' )->with (5 )->willReturn ([]);
389
377
$ productCollection ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([$ productCollectionItem ]);
390
378
391
- $ this ->serializer ->expects ($ this ->once ())
392
- ->method ('serialize ' )
393
- ->with ([$ productCollectionItemData ])
394
- ->willReturn ('result ' );
395
-
396
379
$ this ->productCollectionFactory ->expects ($ this ->any ())->method ('create ' )->willReturn ($ productCollection );
397
380
$ this ->model ->getUsedProducts ($ product );
398
381
}
399
382
400
- public function testGetUsedProductsWithDataInCache ()
401
- {
402
- $ product = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
403
- ->disableOriginalConstructor ()
404
- ->getMock ();
405
- $ childProduct = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
406
- ->disableOriginalConstructor ()
407
- ->getMock ();
408
-
409
- $ dataKey = '_cache_instance_products ' ;
410
- $ usedProductsData = [['first ' ]];
411
- $ usedProducts = [$ childProduct ];
412
-
413
- $ product ->expects ($ this ->once ())
414
- ->method ('hasData ' )
415
- ->with ($ dataKey )
416
- ->willReturn (false );
417
- $ product ->expects ($ this ->once ())
418
- ->method ('setData ' )
419
- ->with ($ dataKey , $ usedProducts );
420
- $ product ->expects ($ this ->any ())
421
- ->method ('getData ' )
422
- ->willReturnOnConsecutiveCalls (1 , $ usedProducts );
423
-
424
- $ childProduct ->expects ($ this ->once ())
425
- ->method ('setData ' )
426
- ->with ($ usedProductsData [0 ]);
427
-
428
- $ this ->productFactory ->expects ($ this ->once ())
429
- ->method ('create ' )
430
- ->willReturn ($ childProduct );
431
-
432
- $ this ->cache ->expects ($ this ->once ())
433
- ->method ('load ' )
434
- ->willReturn ($ usedProductsData );
435
-
436
- $ this ->serializer ->expects ($ this ->once ())
437
- ->method ('unserialize ' )
438
- ->with ($ usedProductsData )
439
- ->willReturn ($ usedProductsData );
440
-
441
- $ this ->assertEquals ($ usedProducts , $ this ->model ->getUsedProducts ($ product ));
442
- }
443
-
444
383
/**
445
384
* @param int $productStore
446
385
*
@@ -878,12 +817,12 @@ public function testSetImageFromChildProduct()
878
817
->method ('getLinkField ' )
879
818
->willReturn ('link ' );
880
819
$ productMock ->expects ($ this ->any ())->method ('hasData ' )
881
- ->withConsecutive (['store_id ' ], [ ' _cache_instance_products ' ])
882
- ->willReturnOnConsecutiveCalls (true , true );
820
+ ->withConsecutive (['_cache_instance_products ' ])
821
+ ->willReturnOnConsecutiveCalls (true );
883
822
884
823
$ productMock ->expects ($ this ->any ())->method ('getData ' )
885
- ->withConsecutive (['image ' ], ['image ' ], ['link ' ], [ ' store_id ' ], [ ' _cache_instance_products ' ])
886
- ->willReturnOnConsecutiveCalls ('no_selection ' , 'no_selection ' , 1 , 1 , [$ childProductMock ]);
824
+ ->withConsecutive (['image ' ], ['image ' ], ['_cache_instance_products ' ])
825
+ ->willReturnOnConsecutiveCalls ('no_selection ' , 'no_selection ' , [$ childProductMock ]);
887
826
888
827
$ childProductMock ->expects ($ this ->any ())->method ('getData ' )->with ('image ' )->willReturn ('image_data ' );
889
828
$ productMock ->expects ($ this ->once ())->method ('setImage ' )->with ('image_data ' )->willReturnSelf ();
0 commit comments