Exemplo n.º 1
0
    public function testEmail()
    {
        $orderId = 10000031;
        $this->request->expects($this->once())
            ->method('getParam')
            ->with('order_id')
            ->will($this->returnValue($orderId));
        $this->orderRepositoryMock->expects($this->once())
            ->method('get')
            ->with($orderId)
            ->willReturn($this->orderMock);
        $this->orderMock->expects($this->atLeastOnce())
            ->method('getEntityId')
            ->will($this->returnValue($orderId));
        $this->orderManagementMock->expects($this->once())
            ->method('notify')
            ->with($orderId)
            ->willReturn(true);
        $this->messageManager->expects($this->once())
            ->method('addSuccess')
            ->with('You sent the order email.');
        $this->resultRedirect->expects($this->once())
            ->method('setPath')
            ->with('sales/order/view', ['order_id' => $orderId])
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Redirect',
            $this->orderEmail->executeInternal()
        );
        $this->assertEquals($this->response, $this->orderEmail->getResponse());
    }
Exemplo n.º 2
0
 public function testExecuteOneOrderPutOnHold()
 {
     $order1 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $order2 = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $orders = [$order1, $order2];
     $countOrders = count($orders);
     $this->orderCollectionMock->expects($this->any())->method('getItems')->willReturn($orders);
     $order1->expects($this->once())->method('canHold')->willReturn(true);
     $this->orderManagementMock->expects($this->once())->method('hold');
     $this->orderCollectionMock->expects($this->once())->method('count')->willReturn($countOrders);
     $order2->expects($this->once())->method('canHold')->willReturn(false);
     $this->messageManagerMock->expects($this->once())->method('addError')->with('1 order(s) were not put on hold.');
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('You have put 1 order(s) on hold.');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf();
     $this->massAction->execute();
 }