Beispiel #1
0
 public function testExecute()
 {
     $orderId = 1;
     $invoiceId = 2;
     $invoiceData = [];
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->requestMock->expects($this->at(1))->method('getParam')->with('invoice_id')->will($this->returnValue($invoiceId));
     $this->requestMock->expects($this->at(2))->method('getParam')->with('invoice', [])->will($this->returnValue($invoiceData));
     $this->invoiceLoaderMock->expects($this->once())->method('load')->with($orderId, $invoiceId, $invoiceData);
     $this->assertNull($this->controller->execute());
 }
 public function testExecute()
 {
     $invoiceId = 2;
     $this->requestMock->expects($this->once())->method('getParam')->with('invoice_id')->will($this->returnValue($invoiceId));
     $invoiceMock = $this->getMock('Magento\\Sales\\Model\\Order\\Invoice', [], [], '', false);
     $invoiceMock->expects($this->once())->method('load')->willReturnSelf();
     $pdfMock = $this->getMock('Magento\\Sales\\Model\\Order\\Pdf\\Invoice', ['render', 'getPdf'], [], '', false);
     $pdfMock->expects($this->once())->method('getPdf')->willReturnSelf();
     $pdfMock->expects($this->once())->method('render');
     $dateTimeMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateTime', [], [], '', false);
     $this->objectManagerMock->expects($this->at(0))->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
     $this->objectManagerMock->expects($this->at(1))->method('create')->with('Magento\\Sales\\Model\\Order\\Pdf\\Invoice')->willReturn($pdfMock);
     $this->objectManagerMock->expects($this->at(2))->method('get')->with('Magento\\Framework\\Stdlib\\DateTime\\DateTime')->willReturn($dateTimeMock);
     $this->assertNull($this->controller->execute());
 }
 /**
  * {@inheritdoc}
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch');
     if (!$pluginInfo) {
         return parent::dispatch($request);
     } else {
         return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo);
     }
 }
Beispiel #4
0
    public function testExecute()
    {
        $invoiceId = 2;

        $this->requestMock->expects($this->once())
            ->method('getParam')
            ->with('invoice_id')
            ->will($this->returnValue($invoiceId));

        $invoiceMock = $this->getMock('Magento\Sales\Model\Order\Invoice', [], [], '', false);

        $pdfMock = $this->getMock('Magento\Sales\Model\Order\Pdf\Invoice', ['render', 'getPdf'], [], '', false);
        $pdfMock->expects($this->once())
            ->method('getPdf')
            ->willReturnSelf();
        $pdfMock->expects($this->once())
            ->method('render');
        $dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false);

        $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->disableOriginalConstructor()
            ->getMock();
        $invoiceRepository->expects($this->any())
            ->method('get')
            ->willReturn($invoiceMock);

        $this->objectManagerMock->expects($this->at(0))
            ->method('create')
            ->with('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->willReturn($invoiceRepository);
        $this->objectManagerMock->expects($this->at(1))
            ->method('create')
            ->with('Magento\Sales\Model\Order\Pdf\Invoice')
            ->willReturn($pdfMock);
        $this->objectManagerMock->expects($this->at(2))
            ->method('get')
            ->with('Magento\Framework\Stdlib\DateTime\DateTime')
            ->willReturn($dateTimeMock);

        $this->assertNull($this->controller->executeInternal());
    }