当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::expects方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order\Item::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::expects方法的具体用法?PHP Item::expects怎么用?PHP Item::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order\Item的用法示例。


在下文中一共展示了Item::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetBaseTotalAmount

 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));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:DefaultColumnTest.php

示例2: testSave

 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);
 }
开发者ID:nja78,项目名称:magento2,代码行数:32,代码来源:OrderTest.php

示例3: testCollect

 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));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:SubtotalTest.php

示例4: testProcessRelation

 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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:22,代码来源:RelationTest.php

示例5: testCalcRowTotal

 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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:ItemTest.php

示例6: testCollect

 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));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:DiscountTest.php


注:本文中的Magento\Sales\Model\Order\Item::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。