/** * test compare two items first without options and second with options */ public function testCompareItemWithoutOptionWithCompared() { $this->itemMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getOptions')->will($this->returnValue([$this->getOptionMock('option-1', 1), $this->getOptionMock('option-2', 'option-value'), $this->getOptionMock('option-3', serialize(['value' => 'value-1', 'qty' => 2]))])); $this->itemMock->expects($this->any())->method('getOptions')->will($this->returnValue([])); $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); }
/** * Verify that compare ignores empty options. */ public function testCompareWithEmptyValues() { $this->itemMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->itemMock->expects($this->once())->method('getOptions')->willReturn([$this->getOptionMock('option-1', serialize(['non-empty-option' => 'test', 'empty_option' => '']))]); $this->comparedMock->expects($this->once())->method('getOptions')->willReturn([$this->getOptionMock('option-1', serialize(['non-empty-option' => 'test']))]); $this->assertTrue($this->helper->compare($this->itemMock, $this->comparedMock)); }
/** * Compare items * * @param \Magento\Quote\Model\Quote\Item $item * @return bool */ public function compare($item) { return $this->quoteItemCompare->compare($this, $item); }