@@ -61,12 +61,12 @@ protected function setUp(): void
61
61
);
62
62
$ this ->itemMock = $ this ->getMockBuilder (Item::class)
63
63
->addMethods (['getProductId ' ])
64
- ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' ])
64
+ ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' , ' getSku ' ])
65
65
->setConstructorArgs ($ constrArgs )
66
66
->getMock ();
67
67
$ this ->comparedMock = $ this ->getMockBuilder (Item::class)
68
68
->addMethods (['getProductId ' ])
69
- ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' ])
69
+ ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' , ' getSku ' ])
70
70
->setConstructorArgs ($ constrArgs )
71
71
->getMock ();
72
72
$ this ->optionMock = $ this ->getMockBuilder (Option::class)
@@ -236,4 +236,19 @@ public function testCompareItemWithoutOptionWithCompared()
236
236
->willReturn ([]);
237
237
$ this ->assertFalse ($ this ->helper ->compare ($ this ->itemMock , $ this ->comparedMock ));
238
238
}
239
+
240
+ /**
241
+ * test compare when configurable products has assigned its selected variant sku
242
+ */
243
+ public function testCompareConfigurableProductAndItsVariant ()
244
+ {
245
+ $ this ->itemMock ->expects ($ this ->exactly (2 ))
246
+ ->method ('getSku ' )
247
+ ->willReturn ('cr1-r ' );
248
+ $ this ->comparedMock ->expects ($ this ->once ())
249
+ ->method ('getSku ' )
250
+ ->willReturn ('cr1-r ' );
251
+
252
+ $ this ->assertTrue ($ this ->helper ->compare ($ this ->itemMock , $ this ->comparedMock ));
253
+ }
239
254
}
0 commit comments