/** * 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)); }
/** * test compare */ public function testCompare() { $itemMock = $this->getMock('Magento\\Sales\\Model\\Quote\\Item', [], [], '', false); $this->compareHelper->expects($this->once())->method('compare')->with($this->equalTo($this->model), $this->equalTo($itemMock))->will($this->returnValue(true)); $this->assertTrue($this->model->compare($itemMock)); }
/** * Compare items * * @param \Magento\Sales\Model\Quote\Item $item * @return bool */ public function compare($item) { return $this->_compareHelper->compare($this, $item); }