public function testCollect() { $this->creditmemoMock->expects($this->once())->method('getAllItems')->willReturn([$this->creditmemoItemMock, $this->creditmemoItemMock]); $this->creditmemoItemMock->expects($this->exactly(2))->method('getHasChildren')->willReturn(false); $this->creditmemoItemMock->expects($this->exactly(2))->method('getBaseCost')->willReturn(10); $this->creditmemoItemMock->expects($this->exactly(2))->method('getQty')->willReturn(2); $this->creditmemoMock->expects($this->once())->method('setBaseCost')->with(40)->willReturnSelf(); $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock)); }
public function testProcessRelations() { $this->creditmemoMock->expects($this->once())->method('getId')->willReturn('creditmemo-id-value'); $this->creditmemoMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->itemMock]); $this->creditmemoMock->expects($this->exactly(2))->method('getComments')->willReturn([$this->commentMock]); $this->itemMock->expects($this->once())->method('setParentId')->with('creditmemo-id-value')->willReturnSelf(); $this->itemResourceMock->expects($this->once())->method('save')->with($this->itemMock)->willReturnSelf(); $this->commentResourceMock->expects($this->once())->method('save')->with($this->commentMock)->willReturnSelf(); $this->relationProcessor->processRelation($this->creditmemoMock); }
public function testCollect() { $this->creditmemoMock->expects($this->once())->method('getAllItems')->willReturn([$this->creditmemoItemMock]); $this->creditmemoItemMock->expects($this->atLeastOnce())->method('getOrderItem')->willReturn($this->orderItemMock); $this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(false); $this->creditmemoItemMock->expects($this->once())->method('calcRowTotal')->willReturnSelf(); $this->creditmemoItemMock->expects($this->once())->method('getRowTotal')->willReturn(1); $this->creditmemoItemMock->expects($this->once())->method('getBaseRowTotal')->willReturn(1); $this->creditmemoItemMock->expects($this->once())->method('getRowTotalInclTax')->willReturn(1); $this->creditmemoItemMock->expects($this->once())->method('getBaseRowTotalInclTax')->willReturn(1); $this->creditmemoMock->expects($this->once())->method('setSubtotal')->with(1)->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('setBaseSubtotal')->with(1)->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('setSubtotalInclTax')->with(1)->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('setBaseSubtotalInclTax')->with(1)->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('getGrandTotal')->willReturn(1); $this->creditmemoMock->expects($this->once())->method('setGrandTotal')->with(2)->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('getBaseGrandTotal')->willReturn(1); $this->creditmemoMock->expects($this->once())->method('setBaseGrandTotal')->with(2)->willReturnSelf(); $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock)); }
public function testCollect() { $this->creditmemoMock->expects($this->exactly(2))->method('setDiscountAmount')->willReturnSelf(); $this->creditmemoMock->expects($this->exactly(2))->method('setBaseDiscountAmount')->willReturnSelf(); $this->creditmemoMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock); $this->creditmemoMock->expects($this->once())->method('getBaseShippingAmount')->willReturn(1); $this->orderMock->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn(1); $this->orderMock->expects($this->exactly(2))->method('getBaseShippingAmount')->willReturn(1); $this->orderMock->expects($this->once())->method('getShippingAmount')->willReturn(1); $this->creditmemoMock->expects($this->once())->method('getAllItems')->willReturn([$this->creditmemoItemMock]); $this->creditmemoItemMock->expects($this->atLeastOnce())->method('getOrderItem')->willReturn($this->orderItemMock); $this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(false); $this->orderItemMock->expects($this->once())->method('getDiscountInvoiced')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getBaseDiscountInvoiced')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getQtyInvoiced')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getDiscountRefunded')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getQtyRefunded')->willReturn(0); $this->creditmemoItemMock->expects($this->once())->method('isLast')->willReturn(false); $this->creditmemoItemMock->expects($this->atLeastOnce())->method('getQty')->willReturn(1); $this->creditmemoItemMock->expects($this->exactly(1))->method('setDiscountAmount')->willReturnSelf(); $this->creditmemoItemMock->expects($this->exactly(1))->method('setBaseDiscountAmount')->willReturnSelf(); $this->creditmemoMock->expects($this->exactly(2))->method('roundPrice')->willReturnMap([[1, 'regular', true, 1], [1, 'base', true, 1]]); $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock)); }