Beispiel #1
0
 /**
  * @param bool $noDiscount
  * @param string $couponCode
  * @param string $errorMessage
  * @param string $actualCouponCode
  * @dataProvider isApplyDiscountDataProvider
  */
 public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCouponCode)
 {
     $quote = $this->getMock('Magento\\Quote\\Model\\Quote', ['getCouponCode', 'isVirtual', 'getAllItems'], [], '', false);
     $create = $this->getMock('Magento\\Sales\\Model\\AdminOrder\\Create', [], [], '', false);
     $paramReturnMap = [['customer_id', null, null], ['store_id', null, null], ['currency_id', null, null]];
     $this->request->expects($this->atLeastOnce())->method('getParam')->willReturnMap($paramReturnMap);
     $objectManagerParamMap = [['Magento\\Sales\\Model\\AdminOrder\\Create', $create], ['Magento\\Backend\\Model\\Session\\Quote', $this->session]];
     $this->objectManager->expects($this->atLeastOnce())->method('get')->willReturnMap($objectManagerParamMap);
     $this->eventManager->expects($this->any())->method('dispatch');
     $data = ['coupon' => ['code' => $couponCode]];
     $postReturnMap = [['order', $data], ['reset_shipping', false], ['collect_shipping_rates', false], ['sidebar', false], ['add_product', false], ['', false], ['update_items', false], ['remove_item', 1], ['from', 2], ['move_item', 1], ['to', 2], ['qty', 3], ['payment', false], [null, 'request'], ['payment', false], ['giftmessage', false], ['add_products', false], ['update_items', false]];
     $this->request->expects($this->atLeastOnce())->method('getPost')->willReturnMap($postReturnMap);
     $create->expects($this->once())->method('importPostData')->willReturnSelf();
     $create->expects($this->once())->method('initRuleData')->willReturnSelf();
     $create->expects($this->any())->method('getQuote')->willReturn($quote);
     $address = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', [], [], '', false);
     $create->expects($this->once())->method('getBillingAddress')->willReturn($address);
     $quote->expects($this->any())->method('isVirtual')->willReturn(true);
     $this->request->expects($this->once())->method('has')->with('item')->willReturn(false);
     $create->expects($this->once())->method('saveQuote')->willReturnSelf();
     $this->session->expects($this->any())->method('getQuote')->willReturn($quote);
     $item = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], '', false, true, true, ['getNoDiscount']);
     $quote->expects($this->any())->method('getAllItems')->willReturn([$item]);
     $item->expects($this->any())->method('getNoDiscount')->willReturn($noDiscount);
     if (!$noDiscount) {
         $quote->expects($this->once())->method('getCouponCode')->willReturn($actualCouponCode);
     }
     $errorMessageManager = __($errorMessage, $couponCode);
     $this->escaper->expects($this->once())->method('escapeHtml')->with($couponCode)->willReturn($couponCode);
     $this->messageManager->expects($this->once())->method('addError')->with($errorMessageManager)->willReturnSelf();
     $this->resultForward->expects($this->once())->method('forward')->with('index')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->processData->execute());
 }
Beispiel #2
0
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  */
 public function testExecuteAjax()
 {
     $this->prepareExecute(true);
     $this->resultForwardFactoryMock->expects($this->once())->method('create')->willReturn($this->resultForwardMock);
     $this->resultForwardMock->expects($this->once())->method('forward')->with('grid')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->indexController->execute());
 }
 /**
  * @covers \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction::execute
  */
 public function testExecuteNoCreditmemoId()
 {
     $this->prepareTestExecute();
     $this->resultForwardFactoryMock->expects($this->once())->method('create')->willReturn($this->resultForwardMock);
     $this->resultForwardMock->expects($this->once())->method('forward')->with('noroute')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->printAction->execute());
 }
Beispiel #4
0
 public function testExecuteWithoutTaxClass()
 {
     $this->request->expects($this->once())->method('getParam')->with('tax_class')->willReturn(null);
     $this->forwardFactoryMock->expects($this->once())->method('create')->willReturn($this->resultForward);
     $this->resultForward->expects($this->once())->method('forward')->with('new')->willReturnSelf();
     $this->assertSame($this->resultForward, $this->controller->execute());
 }
 /**
  * @return void
  */
 public function testExecuteNoCreditmemo()
 {
     $this->requestMock->expects($this->once())->method('getParam')->with('creditmemo_id')->willReturn(null);
     $this->resultForwardFactoryMock->expects($this->once())->method('create')->willReturn($this->resultForwardMock);
     $this->resultForwardMock->expects($this->once())->method('forward')->with('noroute')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->controller->execute());
 }
Beispiel #6
0
    public function testEmailNoInvoice()
    {
        $invoiceId = 10000031;
        $this->request->expects($this->once())
            ->method('getParam')
            ->with('invoice_id')
            ->willReturn($invoiceId);

        $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->disableOriginalConstructor()
            ->getMock();
        $invoiceRepository->expects($this->any())
            ->method('get')
            ->willReturn(null);
        $this->objectManager->expects($this->at(0))
            ->method('create')
            ->with('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->willReturn($invoiceRepository);

        $this->resultForwardFactory->expects($this->any())
            ->method('create')
            ->willReturn($this->resultForward);
        $this->resultForward->expects($this->once())
            ->method('forward')
            ->with('noroute')
            ->willReturnSelf();

        $this->assertInstanceOf('Magento\Backend\Model\View\Result\Forward', $this->invoiceEmail->executeInternal());
    }
 /**
  * {@inheritdoc}
  */
 public function renderResult(\Magento\Framework\App\ResponseInterface $response)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'renderResult');
     if (!$pluginInfo) {
         return parent::renderResult($response);
     } else {
         return $this->___callPlugins('renderResult', func_get_args(), $pluginInfo);
     }
 }
Beispiel #8
0
 /**
  * Run test execute method (no shipment)
  */
 public function testExecuteNoShipment()
 {
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $this->loadShipment($orderId, $shipmentId, $shipment, $tracking, null, false);
     $this->resultForwardFactoryMock->expects($this->once())->method('create')->willReturn($this->resultForwardMock);
     $this->resultForwardMock->expects($this->once())->method('forward')->with('noroute')->willReturnSelf();
     $this->assertEquals($this->resultForwardMock, $this->controller->execute());
 }
Beispiel #9
0
 public function testEmailNoInvoice()
 {
     $invoiceId = 10000031;
     $invoiceClassName = 'Magento\\Sales\\Model\\Order\\Invoice';
     $invoice = $this->getMock($invoiceClassName, [], [], '', false);
     $this->request->expects($this->once())->method('getParam')->with('invoice_id')->willReturn($invoiceId);
     $this->objectManager->expects($this->at(0))->method('create')->with($invoiceClassName)->willReturn($invoice);
     $invoice->expects($this->once())->method('load')->with($invoiceId)->willReturn(null);
     $this->resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward);
     $this->resultForward->expects($this->once())->method('forward')->with('noroute')->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->invoiceEmail->execute());
 }
Beispiel #10
0
 /**
  * Forward to edit
  *
  * @return \Magento\Backend\Model\View\Result\Forward
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
     $resultForward = $this->resultForwardFactory->create();
     return $resultForward->forward('edit');
 }
 /**
  * Dispatch request
  *
  * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function execute()
 {
     $resultForward = $this->resultForwardFactory->create();
     return $resultForward->forward('edit');
 }
Beispiel #12
0
    /**
     * @return void
     */
    public function testExecuteNoCreditmemo()
    {
        $this->requestMock->expects($this->any())
            ->method('getParam')
            ->withAnyParameters()
            ->willReturnArgument(0);
        $this->loaderMock->expects($this->once())
            ->method('load')
            ->willReturn(false);
        $this->resultForwardFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultForwardMock);
        $this->resultForwardMock->expects($this->once())
            ->method('forward')
            ->with('noroute')
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Forward',
            $this->controller->executeInternal()
        );
    }