public function testGetBaseTotalAmount() { $baseRowTotal = 10; $baseDiscountAmount = 2; $expectedResult = 8; $this->itemMock->expects($this->once())->method('getBaseRowTotal')->will($this->returnValue($baseRowTotal)); $this->itemMock->expects($this->once())->method('getBaseDiscountAmount')->will($this->returnValue($baseDiscountAmount)); $this->assertEquals($expectedResult, $this->defaultColumn->getBaseTotalAmount($this->itemMock)); }
public function testSave() { $this->orderMock->expects($this->exactly(3))->method('getId')->willReturn(null); $this->orderItemMock->expects($this->once())->method('getChildrenItems')->willReturn([]); $this->orderItemMock->expects($this->once())->method('getQuoteParentItemId')->willReturn(null); $this->orderMock->expects($this->once())->method('setTotalItemCount')->with(1); $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1); $this->orderMock->expects($this->once())->method('getAllItems')->willReturn([$this->orderItemMock]); $this->orderMock->expects($this->once())->method('validateBeforeSave')->willReturnSelf(); $this->orderMock->expects($this->once())->method('beforeSave')->willReturnSelf(); $this->orderMock->expects($this->once())->method('isSaveAllowed')->willReturn(true); $this->orderMock->expects($this->once())->method('getEntityType')->willReturn('order'); $this->orderMock->expects($this->exactly(2))->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->exactly(2))->method('getGroup')->willReturn($this->storeGroupMock); $this->storeMock->expects($this->once())->method('getWebsite')->willReturn($this->websiteMock); $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1); $this->salesSequenceManagerMock->expects($this->once())->method('getSequence')->with('order', 1)->willReturn($this->salesSequenceMock); $this->salesSequenceMock->expects($this->once())->method('getNextValue')->willReturn('10000001'); $this->orderMock->expects($this->once())->method('setIncrementId')->with('10000001')->willReturnSelf(); $this->orderMock->expects($this->once())->method('getIncrementId')->willReturn(null); $this->orderMock->expects($this->once())->method('getData')->willReturn(['increment_id' => '10000001']); $this->objectRelationProcessorMock->expects($this->once())->method('validateDataIntegrity')->with(null, ['increment_id' => '10000001']); $this->relationCompositeMock->expects($this->once())->method('processRelations')->with($this->orderMock); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock); $this->adapterMock->expects($this->any())->method('quoteInto'); $this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([])); $this->adapterMock->expects($this->any())->method('update'); $this->adapterMock->expects($this->any())->method('lastInsertId'); $this->orderMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->orderMock)->will($this->returnValue(true)); $this->resource->save($this->orderMock); }
/** * @dataProvider canShowPriceInfoDataProvider */ public function testCanShowPriceInfo($parentItem, $productOptions, $result) { $this->model->setItem($this->orderItem); $this->orderItem->expects($this->any())->method('getOrderItem')->will($this->returnSelf()); $this->orderItem->expects($this->any())->method('getParentItem')->will($this->returnValue($parentItem)); $this->orderItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); $this->assertSame($result, $this->model->canShowPriceInfo($this->orderItem)); }
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 testProcessRelation() { $this->addressHandlerMock->expects($this->once())->method('removeEmptyAddresses')->with($this->orderMock)->willReturnSelf(); $this->addressHandlerMock->expects($this->once())->method('process')->with($this->orderMock)->willReturnSelf(); $this->orderMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->orderItemMock]); $this->orderMock->expects($this->exactly(3))->method('getId')->willReturn('order-id-value'); $this->orderItemMock->expects($this->once())->method('setOrderId')->with('order-id-value')->willReturnSelf(); $this->orderItemMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf(); $this->orderItemRepositoryMock->expects($this->once())->method('save')->with($this->orderItemMock)->willReturnSelf(); $this->orderMock->expects($this->exactly(2))->method('getPayment')->willReturn($this->orderPaymentMock); $this->orderPaymentMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf(); $this->orderPaymentMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf(); $this->orderPaymentResourceMock->expects($this->once())->method('save')->with($this->orderPaymentMock)->willReturnSelf(); $this->orderMock->expects($this->exactly(2))->method('getStatusHistories')->willReturn([$this->orderStatusHistoryMock]); $this->orderStatusHistoryMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf(); $this->orderStatusHistoryMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf(); $this->statusHistoryResource->expects($this->once())->method('save')->with($this->orderStatusHistoryMock)->willReturnSelf(); $this->orderMock->expects($this->exactly(2))->method('getRelatedObjects')->willReturn([$this->orderInvoiceMock]); $this->orderInvoiceMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf(); $this->orderInvoiceMock->expects($this->once())->method('save')->willReturnSelf(); $this->relationProcessor->processRelation($this->orderMock); }
public function testCalcRowTotal() { $this->item->setData(['order_item_id' => 1, 'qty' => 2]); $this->item->setInvoice($this->invoiceMock); $this->invoiceMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock); $this->orderMock->expects($this->once())->method('getItemById')->with(1)->willReturn($this->orderItemMock); $this->orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getRowTotal')->willReturn(2); $this->orderItemMock->expects($this->once())->method('getRowInvoiced')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getBaseRowTotal')->willReturn(2); $this->orderItemMock->expects($this->once())->method('getBaseRowInvoiced')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getRowTotalInclTax')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getBaseRowTotalInclTax')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getQtyToInvoice')->willReturn(1); $this->orderItemMock->expects($this->once())->method('getQtyInvoiced')->willReturn(0); $this->invoiceMock->expects($this->exactly(4))->method('roundPrice')->willReturnMap([[2, 'regular', false, 2], [2, 'base', false, 2], [2, 'including', false, 2], [2, 'including_base', false, 2]]); $this->assertEquals($this->item->calcRowTotal(), $this->item); }
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)); }