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 testEmail()
 {
     $orderId = 10000031;
     $orderClassName = 'Magento\\Sales\\Model\\Order';
     $orderNotifierClassName = 'Magento\\Sales\\Model\\OrderNotifier';
     $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false);
     $cmNotifier = $this->getMock($orderNotifierClassName, ['notify', '__wakeup'], [], '', false);
     $this->request->expects($this->once())->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->objectManager->expects($this->at(0))->method('create')->with($orderClassName)->will($this->returnValue($order));
     $order->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf());
     $order->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($orderId));
     $this->objectManager->expects($this->at(1))->method('create')->with($orderNotifierClassName)->will($this->returnValue($cmNotifier));
     $cmNotifier->expects($this->once())->method('notify')->will($this->returnValue(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->execute());
     $this->assertEquals($this->response, $this->orderEmail->getResponse());
 }