Ejemplo n.º 1
0
 public function testCancel()
 {
     $orderItemMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['setQtyRefunded', 'getQtyRefunded', 'getTaxRefunded', 'getBaseTaxAmount', 'getQtyOrdered', 'setTaxRefunded', 'setDiscountTaxCompensationRefunded', 'getDiscountTaxCompensationRefunded', 'getDiscountTaxCompensationAmount'])->getMock();
     $orderItemMock->expects($this->once())->method('getQtyRefunded')->willReturn(1);
     $orderItemMock->expects($this->once())->method('setQtyRefunded')->with(0);
     $orderItemMock->expects($this->once())->method('getTaxRefunded')->willReturn(10);
     $orderItemMock->expects($this->once())->method('getBaseTaxAmount')->willReturn(5);
     $orderItemMock->expects($this->exactly(2))->method('getQtyOrdered')->willReturn(1);
     $orderItemMock->expects($this->once())->method('setTaxRefunded')->with(5);
     $orderItemMock->expects($this->once())->method('setDiscountTaxCompensationRefunded')->with(0);
     $orderItemMock->expects($this->once())->method('getDiscountTaxCompensationRefunded')->willReturn(10);
     $orderItemMock->expects($this->once())->method('getDiscountTaxCompensationAmount')->willReturn(10);
     $this->item->setData('qty', 1);
     $this->item->setOrderItem($orderItemMock);
     $result = $this->item->cancel();
     $this->assertInstanceOf('Magento\\Sales\\Model\\Order\\Creditmemo\\Item', $result);
 }