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


PHP Order::expects方法代码示例

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


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

示例1: testSave

 public function testSave()
 {
     $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->once())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getGroup')->willReturn($this->storeGroupMock);
     $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:kid17,项目名称:magento2,代码行数:25,代码来源:OrderTest.php

示例2: testCanVoid

 /**
  * @dataProvider canVoidDataProvider
  * @param bool $canVoid
  */
 public function testCanVoid($canVoid)
 {
     $this->_orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
     $this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->with($this->equalTo($this->_model))->will($this->returnValue($canVoid));
     $this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
     $this->assertEquals($canVoid, $this->_model->canVoid());
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:11,代码来源:InvoiceTest.php

示例3: testSaveDownloadableOrderItem

 public function testSaveDownloadableOrderItem()
 {
     $itemId = 100;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($this->orderMock);
     $itemMock->expects($this->any())->method('getId')->willReturn($itemId);
     $itemMock->expects($this->any())->method('getProductType')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $this->orderMock->expects($this->once())->method('getStoreId')->willReturn(10500);
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeId')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $productType = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Product\\Type')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeInstance')->willReturn($productType);
     $product->expects($this->once())->method('setStoreId')->with(10500)->willReturnSelf();
     $product->expects($this->once())->method('load')->willReturnSelf();
     $this->productFactory->expects($this->once())->method('create')->willReturn($product);
     $linkItem = $this->createLinkItem(12, 12, true, 'pending');
     $this->itemFactory->expects($this->once())->method('create')->willReturn($linkItem);
     $productType->expects($this->once())->method('getLinks')->willReturn([123 => $linkItem]);
     $itemMock->expects($this->once())->method('getProductOptionByCode')->willReturn([123]);
     $itemMock->expects($this->once())->method('getProduct')->willReturn(null);
     $purchasedLink = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Link\\Purchased')->disableOriginalConstructor()->setMethods(['load', 'setLinkSectionTitle', 'save'])->getMock();
     $purchasedLink->expects($this->once())->method('load')->with($itemId, 'order_item_id')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('setLinkSectionTitle')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('save')->willReturnSelf();
     $this->purchasedFactory->expects($this->any())->method('create')->willReturn($purchasedLink);
     $event = new \Magento\Framework\DataObject(['item' => $itemMock]);
     $observer = new \Magento\Framework\Event\Observer(['event' => $event]);
     $this->saveDownloadableOrderItemObserver->execute($observer);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:SaveDownloadableOrderItemObserverTest.php

示例4: testGetAllItems

 public function testGetAllItems()
 {
     $items = [new \Magento\Framework\Object(['parent_item' => 'parent item 1', 'name' => 'name 1', 'qty_ordered' => 1, 'base_price' => 0.1]), new \Magento\Framework\Object(['parent_item' => 'parent item 2', 'name' => 'name 2', 'qty_ordered' => 2, 'base_price' => 1.2]), new \Magento\Framework\Object(['parent_item' => 'parent item 3', 'name' => 'name 3', 'qty_ordered' => 3, 'base_price' => 2.3])];
     $expected = [new \Magento\Framework\Object(['parent_item' => 'parent item 1', 'name' => 'name 1', 'qty' => 1, 'price' => 0.1, 'original_item' => $items[0]]), new \Magento\Framework\Object(['parent_item' => 'parent item 2', 'name' => 'name 2', 'qty' => 2, 'price' => 1.2, 'original_item' => $items[1]]), new \Magento\Framework\Object(['parent_item' => 'parent item 3', 'name' => 'name 3', 'qty' => 3, 'price' => 2.3, 'original_item' => $items[2]])];
     $this->_orderMock->expects($this->once())->method('getAllItems')->will($this->returnValue($items));
     $this->assertEquals($expected, $this->_model->getAllItems());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:OrderTest.php

示例5: testGetOrder

 public function testGetOrder()
 {
     $orderId = 100000041;
     $this->model->setOrderId($orderId);
     $entityName = 'invoice';
     $this->orderMock->expects($this->atLeastOnce())->method('setHistoryEntityName')->with($entityName)->will($this->returnSelf());
     $this->assertEquals($this->orderMock, $this->model->getOrder());
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:8,代码来源:InvoiceTest.php

示例6: testSendEmailWhenRedirectUrlExists

 public function testSendEmailWhenRedirectUrlExists()
 {
     $this->paymentMock->expects($this->once())->method('getOrderPlaceRedirectUrl')->willReturn(false);
     $this->orderMock->expects($this->once())->method('getCanSendNewEmailFlag');
     $this->orderSenderMock->expects($this->never())->method('send');
     $this->loggerMock->expects($this->never())->method('critical');
     $this->model->execute($this->observerMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:SubmitObserverTest.php

示例7: setUp

 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->authorizationMock = $this->getMock('\\Magento\\Framework\\Authorization', [], [], '', false);
     $this->coreRegistryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->orderMock = $this->getMock('\\Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->paymentMock = $this->getMock('\\Magento\\Sales\\Model\\Order\\Payment', [], [], '', false);
     $this->coreRegistryMock->expects($this->any())->method('registry')->with('current_order')->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->transactionsTab = $this->objectManager->getObject('Magento\\Sales\\Block\\Adminhtml\\Order\\View\\Tab\\Transactions', ['authorization' => $this->authorizationMock, 'registry' => $this->coreRegistryMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:TransactionsTest.php

示例8: testCheckSetStateProcessing

 /**
  * test check order - set state processing
  */
 public function testCheckSetStateProcessing()
 {
     $this->orderMock->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->orderMock->expects($this->once())->method('isCanceled')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canUnhold')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canInvoice')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canShip')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('getState')->will($this->returnValue(Order::STATE_NEW));
     $this->orderMock->expects($this->once())->method('getIsInProcess')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('setState')->with(Order::STATE_PROCESSING)->will($this->returnSelf());
     $this->assertEquals($this->state, $this->state->check($this->orderMock));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:StateTest.php

示例9: testExecute

    /**
     * @covers \Magento\Sales\Controller\Adminhtml\Order\View::executeInternal
     */
    public function testExecute()
    {
        $id = 111;
        $titlePart = '#111';
        $this->initOrder();
        $this->initOrderSuccess($id);
        $this->prepareRedirect();
        $this->initAction();

        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getConfig')
            ->willReturn($this->pageConfigMock);
        $this->pageConfigMock->expects($this->atLeastOnce())
            ->method('getTitle')
            ->willReturn($this->pageTitleMock);
        $this->orderMock->expects($this->atLeastOnce())
            ->method('getIncrementId')
            ->willReturn($id);
        $this->pageTitleMock->expects($this->exactly(2))
            ->method('prepend')
            ->withConsecutive(
                ['Orders'],
                [$titlePart]
            )
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Page',
            $this->viewAction->executeInternal()
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:34,代码来源:ViewTest.php

示例10: initOrderMock

 private function initOrderMock($orderId, $state)
 {
     $this->orderFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->orderMock));
     $this->orderMock->expects($this->once())->method('loadByIncrementId')->with($orderId)->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($orderId));
     $this->orderMock->expects($this->once())->method('getState')->will($this->returnValue($state));
 }
开发者ID:Zash22,项目名称:magento,代码行数:7,代码来源:ReturnUrlTest.php

示例11: testUnHold

 public function testUnHold()
 {
     $this->orderRepositoryMock->expects($this->once())->method('get')->with(123)->willReturn($this->orderMock);
     $this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock)->willReturn($this->orderMock);
     $this->orderMock->expects($this->once())->method('unHold')->willReturn($this->orderMock);
     $this->assertTrue($this->orderService->unHold(123));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:OrderServiceTest.php

示例12: testSetLinkStatusEmptyOrder

 public function testSetLinkStatusEmptyOrder()
 {
     $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock));
     $this->eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
     $this->orderMock->expects($this->once())->method('getId')->willReturn(null);
     $result = $this->setLinkStatusObserver->execute($this->observerMock);
     $this->assertInstanceOf('\\Magento\\Downloadable\\Observer\\SetLinkStatusObserver', $result);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:SetLinkStatusObserverTest.php

示例13: testRemoveEmptyAddresses

 /**
  * Test method removeEmptyAddresses
  */
 public function testRemoveEmptyAddresses()
 {
     $this->orderMock->expects($this->once())->method('hasBillingAddressId')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('getBillingAddressId')->will($this->returnValue(null));
     $this->orderMock->expects($this->once())->method('unsBillingAddressId')->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('hasShippingAddressId')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('getShippingAddressId')->will($this->returnValue(null));
     $this->orderMock->expects($this->once())->method('unsShippingAddressId')->will($this->returnSelf());
     $this->assertEquals($this->address, $this->address->removeEmptyAddresses($this->orderMock));
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:13,代码来源:AddressTest.php

示例14: testSave

 public function testSave()
 {
     $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->orderMock->expects($this->once())->method('hasDataChanges')->will($this->returnValue(true));
     $this->resource->save($this->orderMock);
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:11,代码来源:OrderTest.php

示例15: testExecuteSuccess

 public function testExecuteSuccess()
 {
     $params = ['success' => 1, 'controller_action_name' => 'action', 'x_invoice_num' => 1];
     $this->requestMock->expects($this->once())->method('getParams')->willReturn($params);
     $this->helperMock->expects($this->once())->method('getSuccessOrderUrl')->willReturn('redirect_parent_url');
     $this->directpostSessionMock->expects($this->once())->method('unsetData')->with('quote_id');
     $this->orderMock->expects($this->once())->method('getId')->willReturn(null);
     $this->sessionQuoteMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($this->orderMock);
     $this->adminOrderCreateMock->expects($this->atLeastOnce())->method('getSession')->willReturn($this->sessionQuoteMock);
     $this->coreRegistryMock->expects($this->once())->method('register')->with(Iframe::REGISTRY_KEY);
     $this->assertInstanceOf('\\Magento\\Framework\\View\\Result\\Layout', $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:RedirectTest.php


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