@@ -61,12 +61,12 @@ protected function setUp(): void
6161 );
6262 $ this ->itemMock = $ this ->getMockBuilder (Item::class)
6363 ->addMethods (['getProductId ' ])
64- ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' ])
64+ ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' , ' getSku ' ])
6565 ->setConstructorArgs ($ constrArgs )
6666 ->getMock ();
6767 $ this ->comparedMock = $ this ->getMockBuilder (Item::class)
6868 ->addMethods (['getProductId ' ])
69- ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' ])
69+ ->onlyMethods (['__wakeup ' , 'getOptions ' , 'getOptionsByCode ' , ' getSku ' ])
7070 ->setConstructorArgs ($ constrArgs )
7171 ->getMock ();
7272 $ this ->optionMock = $ this ->getMockBuilder (Option::class)
@@ -236,4 +236,19 @@ public function testCompareItemWithoutOptionWithCompared()
236236 ->willReturn ([]);
237237 $ this ->assertFalse ($ this ->helper ->compare ($ this ->itemMock , $ this ->comparedMock ));
238238 }
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+ }
239254}
0 commit comments