protected function setUp()
 {
     $this->productBuilder = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder', ['build'], [], '', false);
     $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', 'setAttributeSetId'])->getMock();
     $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
     $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
     $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
     $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
     $this->resultPage = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout);
     $this->resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->initializationHelper = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false);
     $this->productFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\ProductFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJsonFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\JsonFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson);
     $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory];
     $this->action = (new ObjectManagerHelper($this))->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Validate', ['context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, 'resultPageFactory' => $resultPageFactory, 'resultForwardFactory' => $resultForwardFactory, 'initializationHelper' => $this->initializationHelper, 'resultJsonFactory' => $this->resultJsonFactory, 'productFactory' => $this->productFactory]);
 }
Example #2
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipmentLoader = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], [], '', false);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'])->getMockForAbstractClass();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getObjectManager')->willReturn($this->objectManager);
     $this->context->expects($this->once())->method('getSession')->willReturn($this->session);
     $this->context->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlag);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->shipmentEmail = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\Email', ['context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response]);
 }
 public function testExecute()
 {
     $path = '*/*';
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->messageManager->expects($this->once())->method('addSuccess')->with(__('We updated lifetime statistic.'));
     $this->objectManager->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Resource\\Report\\Order')->willReturn($this->order);
     $this->resultRedirect->expects($this->once())->method('setPath')->with($path)->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->refreshStatisticsController->execute());
 }
Example #4
0
 protected function setUp()
 {
     $this->attributeHelper = $this->getMock('Magento\\Catalog\\Helper\\Product\\Edit\\Action\\Attribute', ['getProductIds', 'getSelectedStoreId', 'getStoreWebsiteId'], [], '', false);
     $this->dataObjectHelperMock = $this->getMockBuilder('\\Magento\\Framework\\Api\\DataObjectHelper')->disableOriginalConstructor()->getMock();
     $this->stockIndexerProcessor = $this->getMock('Magento\\CatalogInventory\\Model\\Indexer\\Stock\\Processor', ['reindexList'], [], '', false);
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirectFactory->expects($this->atLeastOnce())->method('create')->willReturn($resultRedirect);
     $this->prepareContext();
     $this->object = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Action\\Attribute\\Save', ['context' => $this->context, 'attributeHelper' => $this->attributeHelper, 'stockIndexerProcessor' => $this->stockIndexerProcessor, 'dataObjectHelper' => $this->dataObjectHelperMock]);
 }
Example #5
0
 public function testEditActionBlockNoExists()
 {
     $blockId = 1;
     $this->requestMock->expects($this->once())->method('getParam')->with('block_id')->willReturn($blockId);
     $this->blockMock->expects($this->once())->method('load')->with($blockId);
     $this->blockMock->expects($this->once())->method('getId')->willReturn(null);
     $this->messageManagerMock->expects($this->once())->method('addError')->with(__('This block no longer exists.'));
     $this->resultRedirectFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($this->resultRedirectMock);
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->editController->execute());
 }
Example #6
0
    /**
     * @return void
     */
    public function testExecute()
    {
        $creditmemoId = '111';

        $this->requestMock->expects($this->once())
            ->method('getParam')
            ->with('creditmemo_id')
            ->willReturn($creditmemoId);
        $this->objectManagerMock->expects($this->once())
            ->method('create')
            ->with('Magento\Sales\Api\CreditmemoManagementInterface')
            ->willReturn($this->creditmemoManagementMock);
        $this->creditmemoManagementMock->expects($this->once())
            ->method('cancel')
            ->with($creditmemoId);
        $this->messageManagerMock->expects($this->once())
            ->method('addSuccess')
            ->with('The credit memo has been canceled.');
        $this->resultRedirectFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultRedirectMock);
        $this->resultRedirectMock->expects($this->once())
            ->method('setPath')
            ->with('sales/*/view', ['creditmemo_id' => $creditmemoId])
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Redirect',
            $this->controller->executeInternal()
        );
    }
Example #7
0
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface', [], [], '', false);
     $this->requestMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getParam']);
     $this->blockMock = $this->getMockBuilder('Magento\\Cms\\Model\\Block')->disableOriginalConstructor()->setMethods(['load', 'delete'])->getMock();
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManager\\ObjectManager')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->setMethods(['setPath'])->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirectFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock = $this->getMock('\\Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactoryMock);
     $this->deleteController = $this->objectManager->getObject('Magento\\Cms\\Controller\\Adminhtml\\Block\\Delete', ['context' => $this->contextMock]);
 }
 protected function setUp()
 {
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods([])->getMockForAbstractClass();
     $this->response = $this->getMockBuilder('\\Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->setMethods([])->getMockForAbstractClass();
     $this->objectManager = $this->getMockBuilder('\\Magento\\Framework\\ObjectManagerInterface')->disableOriginalConstructor()->setMethods(['create'])->getMockForAbstractClass();
     $this->messageManager = $this->getMockBuilder('\\Magento\\Framework\\Message\\ManagerInterface')->disableOriginalConstructor()->setMethods(['addSuccess', 'addError'])->getMockForAbstractClass();
     $this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getRequest', 'getResponse', 'getObjectManager', 'getMessageManager'])->disableOriginalConstructor()->getMock();
     $this->context->expects($this->atLeastOnce())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->atLeastOnce())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->messageManager));
     $this->pageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->setMethods([])->disableOriginalConstructor()->getMock();
     $this->redirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->setMethods(['setPath'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory->expects($this->any())->method('create')->will($this->returnValue($this->redirect));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->controller = $this->objectManagerHelper->getObject('Magento\\Search\\Controller\\Adminhtml\\Term\\MassDelete', ['context' => $this->context, 'resultPageFactory' => $this->pageFactory, 'resultRedirectFactory' => $this->redirectFactory]);
 }
Example #9
0
    /**
     * @return void
     */
    public function testExecuteException()
    {
        $invoiceId = 2;

        $message = 'Invoice capturing error';
        $e = new \Exception($message);

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

        $this->invoiceManagement->expects($this->once())
            ->method('setCapture')
            ->with($invoiceId)
            ->will($this->throwException($e));

        $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice')
            ->disableOriginalConstructor()
            ->getMock();

        $this->messageManagerMock->expects($this->once())
            ->method('addError')
            ->with($message);

        $invoiceMock->expects($this->once())
            ->method('getId')
            ->will($this->returnValue($invoiceId));
        $invoiceMock->expects($this->once())
            ->method('getEntityId')
            ->will($this->returnValue($invoiceId));

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

        $this->objectManagerMock->expects($this->once())
            ->method('create')
            ->with('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->willReturn($invoiceRepository);

        $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
            ->disableOriginalConstructor()
            ->setMethods([])
            ->getMock();
        $resultRedirect->expects($this->once())->method('setPath')->with('sales/*/view', ['invoice_id' => $invoiceId]);

        $this->resultRedirectFactoryMock->expects($this->once())
            ->method('create')
            ->will($this->returnValue($resultRedirect));

        $this->assertSame($resultRedirect, $this->controller->executeInternal());
    }
Example #10
0
 public function testExecutePageDirectAccess()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(null);
     $this->request->expects($this->any())->method('getParams')->willReturn([]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn(null);
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->setMethods(['setPath'])->disableOriginalConstructor()->getMock();
     $resultRedirect->expects($this->any())->method('setPath')->with('catalog/product/', ['_current' => true])->willReturnSelf();
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($resultRedirect);
     $this->assertSame($resultRedirect, $this->object->execute());
 }
Example #11
0
 /**
  * @param int $cmId
  */
 protected function prepareRedirect($cmId)
 {
     $this->resultRedirectFactoryMock->expects($this->once())
         ->method('create')
         ->willReturn($this->resultRedirectMock);
     $this->resultRedirectMock->expects($this->once())
         ->method('setPath')
         ->with('sales/order_creditmemo/view', ['creditmemo_id' => $cmId])
         ->willReturnSelf();
 }
Example #12
0
    public function testEmail()
    {
        $invoiceId = 10000031;
        $orderId = 100000030;
        $invoiceClassName = 'Magento\Sales\Model\Order\Invoice';
        $cmNotifierClassName = 'Magento\Sales\Api\InvoiceManagementInterface';
        $invoice = $this->getMock($invoiceClassName, [], [], '', false);
        $invoice->expects($this->once())
            ->method('getEntityId')
            ->willReturn($invoiceId);
        $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
        $order->expects($this->once())
            ->method('getId')
            ->willReturn($orderId);

        $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($invoice);
        $this->objectManager->expects($this->at(0))
            ->method('create')
            ->with('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->willReturn($invoiceRepository);

        $invoice->expects($this->once())
            ->method('getOrder')
            ->willReturn($order);
        $this->objectManager->expects($this->at(1))
            ->method('create')
            ->with($cmNotifierClassName)
            ->willReturn($this->invoiceManagement);

        $this->invoiceManagement->expects($this->once())
            ->method('notify')
            ->with($invoiceId)
            ->willReturn(true);
        $this->messageManager->expects($this->once())
            ->method('addSuccess')
            ->with('You sent the message.');

        $this->resultRedirectFactory->expects($this->atLeastOnce())
            ->method('create')
            ->willReturn($this->resultRedirect);
        $this->resultRedirect->expects($this->once())
            ->method('setPath')
            ->with('sales/invoice/view', ['order_id' => $orderId, 'invoice_id' => $invoiceId])
            ->willReturnSelf();
        $this->assertInstanceOf('Magento\Backend\Model\View\Result\Redirect', $this->invoiceEmail->executeInternal());
    }
Example #13
0
 /**
  * @covers \Magento\Backup\Controller\Adminhtml\Index\Download::execute
  * @param int $time
  * @param bool $exists
  * @param int $existsCount
  * @dataProvider executeBackupNotFoundDataProvider
  */
 public function testExecuteBackupNotFound($time, $exists, $existsCount)
 {
     $type = 'db';
     $this->backupModelMock->expects($this->atLeastOnce())->method('getTime')->willReturn($time);
     $this->backupModelMock->expects($this->exactly($existsCount))->method('exists')->willReturn($exists);
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['time', null, $time], ['type', null, $type]]);
     $this->backupModelFactoryMock->expects($this->once())->method('create')->with($time, $type)->willReturn($this->backupModelMock);
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('backup/*');
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->assertSame($this->resultRedirectMock, $this->downloadController->execute());
 }
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->resultRedirect);
     $this->dataProcessorMock = $this->getMock('Magento\\Cms\\Controller\\Adminhtml\\Block\\PostDataProcessor', ['filter'], [], '', false);
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setFormData'], [], '', false);
     $this->requestMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getParam', 'getPostValue']);
     $this->blockMock = $this->getMockBuilder('Magento\\Cms\\Model\\Block')->disableOriginalConstructor()->getMock();
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface', [], [], '', false);
     $this->eventManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\Event\\ManagerInterface', [], '', false, true, true, ['dispatch']);
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManager\\ObjectManager')->disableOriginalConstructor()->setMethods(['get', 'create'])->getMock();
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->any())->method('getEventManager')->willReturn($this->eventManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->saveController = $this->objectManager->getObject('Magento\\Cms\\Controller\\Adminhtml\\Block\\Save', ['context' => $this->contextMock, 'dataProcessor' => $this->dataProcessorMock]);
 }
Example #15
0
    /**
     * @return void
     */
    public function testExecute()
    {
        $id = '111';

        $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction')
            ->disableOriginalConstructor()
            ->getMock();
        $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order')
            ->disableOriginalConstructor()
            ->getMock();
        $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice')
            ->disableOriginalConstructor()
            ->getMock();

        $this->requestMock->expects($this->any())
            ->method('getParam')
            ->withAnyParameters()
            ->willReturnArgument(0);
        $this->loaderMock->expects($this->once())
            ->method('load')
            ->willReturn($this->creditmemoMock);
        $this->objectManagerMock->expects($this->once())
            ->method('create')
            ->with('Magento\Framework\DB\Transaction')
            ->willReturn($transactionMock);
        $this->creditmemoMock->expects($this->any())
            ->method('getOrder')
            ->willReturn($orderMock);
        $this->creditmemoMock->expects($this->any())
            ->method('getInvoice')
            ->willReturn($invoiceMock);
        $this->messageManagerMock->expects($this->once())
            ->method('addSuccess')
            ->with('You voided the credit memo.');
        $this->resultRedirectFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultRedirectMock);
        $this->creditmemoMock->expects($this->atLeastOnce())
            ->method('getId')
            ->willReturn($id);
        $this->resultRedirectMock->expects($this->once())
            ->method('setPath')
            ->with('sales/*/view', ['creditmemo_id' => $id])
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Redirect',
            $this->controller->executeInternal()
        );
    }
Example #16
0
 /**
  * Test saveAction when was credit memo total is not positive
  */
 public function testSaveActionWithNegativeCreditmemo()
 {
     $data = ['comment_text' => ''];
     $this->_requestMock->expects($this->once())->method('getPost')->with('creditmemo')->will($this->returnValue($data));
     $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue(null));
     $creditmemoMock = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', ['load', 'getGrandTotal', 'getAllowZeroGrandTotal', '__wakeup'], [], '', false);
     $creditmemoMock->expects($this->once())->method('getGrandTotal')->will($this->returnValue('0'));
     $creditmemoMock->expects($this->once())->method('getAllowZeroGrandTotal')->will($this->returnValue(false));
     $this->memoLoaderMock->expects($this->once())->method('load')->will($this->returnValue($creditmemoMock));
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/new', ['_current' => true])->willReturnSelf();
     $this->_setSaveActionExpectationForMageCoreException($data, 'The credit memo\'s total must be positive.');
     $this->_controller->execute();
 }
Example #17
0
 public function testExecuteNoOrder()
 {
     $orderId = 1;
     $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', [])->will($this->returnValue($invoiceData));
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['load', 'getId', 'canInvoice'])->getMock();
     $orderMock->expects($this->once())->method('load')->with($orderId)->willReturnSelf();
     $orderMock->expects($this->once())->method('getId')->willReturn(null);
     $this->objectManagerMock->expects($this->at(0))->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($orderMock);
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRedirect->expects($this->once())->method('setPath')->with('sales/order/view', ['order_id' => $orderId]);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRedirect));
     $this->assertSame($resultRedirect, $this->controller->execute());
 }
 public function testSaveWithException()
 {
     $scope = 'sadfa';
     $scopeId = 0;
     $this->redirectFactory->expects($this->once())->method('create')->willReturn($this->redirect);
     $this->request->expects($this->exactly(2))->method('getParam')->withConsecutive(['scope'], ['scope_id'])->willReturnOnConsecutiveCalls($scope, $scopeId);
     $this->request->expects($this->once())->method('getParams')->willReturn(['header_default_title' => 'Default title']);
     $this->request->expects($this->once())->method('getFiles')->willReturn($this->fileParams);
     $this->fileParams->expects($this->once())->method('toArray')->willReturn(['header_logo' => ['tmp_name' => '', 'error' => 4]]);
     $this->configFactory->expects($this->once())->method('create')->with($scope, $scopeId, ['header_default_title' => 'Default title'])->willReturn($this->designConfig);
     $exception = new \Exception(__('Exception message'));
     $this->designConfigRepository->expects($this->once())->method('save')->with($this->designConfig)->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addException')->with($exception, 'Something went wrong while saving this configuration: Exception message');
     $this->dataPersistor->expects($this->once())->method('set')->with('theme_design_config', ['header_default_title' => 'Default title']);
     $this->redirect->expects($this->once())->method('setPath')->with('theme/design_config/edit', ['scope' => $scope, 'scope_id' => $scopeId]);
     $this->assertSame($this->redirect, $this->controller->execute());
 }
Example #19
0
 /**
  * @return void
  */
 public function testExecuteModelException()
 {
     $invoiceId = 2;
     $message = 'test message';
     $e = new \Magento\Framework\Exception\LocalizedException(__($message));
     $this->requestMock->expects($this->once())->method('getParam')->with('invoice_id')->will($this->returnValue($invoiceId));
     $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
     $invoiceMock->expects($this->once())->method('load')->with($invoiceId)->willReturnSelf();
     $invoiceMock->expects($this->once())->method('void')->will($this->throwException($e));
     $invoiceMock->expects($this->once())->method('getId')->will($this->returnValue($invoiceId));
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
     $this->messageManagerMock->expects($this->once())->method('addError');
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRedirect->expects($this->once())->method('setPath')->with('sales/*/view', ['invoice_id' => $invoiceId]);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRedirect));
     $this->assertSame($resultRedirect, $this->controller->execute());
 }
Example #20
0
 public function testEmail()
 {
     $invoiceId = 10000031;
     $orderId = 100000030;
     $invoiceClassName = 'Magento\\Sales\\Model\\Order\\Invoice';
     $cmNotifierClassName = 'Magento\\Sales\\Model\\Order\\InvoiceNotifier';
     $invoice = $this->getMock($invoiceClassName, [], [], '', false);
     $notifier = $this->getMock($cmNotifierClassName, [], [], '', false);
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $order->expects($this->once())->method('getId')->willReturn($orderId);
     $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)->willReturnSelf();
     $invoice->expects($this->once())->method('getOrder')->willReturn($order);
     $this->objectManager->expects($this->at(1))->method('create')->with($cmNotifierClassName)->willReturn($notifier);
     $notifier->expects($this->once())->method('notify')->willReturn(true);
     $this->messageManager->expects($this->once())->method('addSuccess')->with('We sent the message.');
     $this->resultRedirectFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->resultRedirect);
     $this->resultRedirect->expects($this->once())->method('setPath')->with('sales/invoice/view', ['order_id' => $orderId, 'invoice_id' => $invoiceId])->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->invoiceEmail->execute());
 }
Example #21
0
 /**
  * Prepare required values
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->_response = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http')->disableOriginalConstructor()->setMethods(['setRedirect', 'getHeader', '__wakeup'])->getMock();
     $this->_response->expects($this->any())->method('getHeader')->with($this->equalTo('X-Frame-Options'))->will($this->returnValue(true));
     $this->_objectManager = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->setMethods(['get', 'create'])->getMock();
     $frontControllerMock = $this->getMockBuilder('Magento\\Framework\\App\\FrontController')->disableOriginalConstructor()->getMock();
     $actionFlagMock = $this->getMockBuilder('Magento\\Framework\\App\\ActionFlag')->disableOriginalConstructor()->getMock();
     $this->_session = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->setMethods(['setIsUrlNotice', '__wakeup'])->getMock();
     $this->_session->expects($this->any())->method('setIsUrlNotice');
     $this->_helper = $this->getMockBuilder('Magento\\Backend\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getUrl'])->getMock();
     $this->messageManager = $this->getMockBuilder('Magento\\Framework\\Message\\Manager')->disableOriginalConstructor()->setMethods(['addSuccess', 'addMessage', 'addException'])->getMock();
     $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $contextArgs = ['getHelper', 'getSession', 'getAuthorization', 'getTranslator', 'getObjectManager', 'getFrontController', 'getActionFlag', 'getMessageManager', 'getLayoutFactory', 'getEventManager', 'getRequest', 'getResponse', 'getTitle', 'getView', 'getResultRedirectFactory'];
     $contextMock = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->setMethods($contextArgs)->getMock();
     $contextMock->expects($this->any())->method('getRequest')->willReturn($this->_request);
     $contextMock->expects($this->any())->method('getResponse')->willReturn($this->_response);
     $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->_objectManager);
     $contextMock->expects($this->any())->method('getFrontController')->willReturn($frontControllerMock);
     $contextMock->expects($this->any())->method('getActionFlag')->willReturn($actionFlagMock);
     $contextMock->expects($this->any())->method('getHelper')->willReturn($this->_helper);
     $contextMock->expects($this->any())->method('getSession')->willReturn($this->_session);
     $contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager);
     $titleMock = $this->getMockBuilder('\\Magento\\Framework\\App\\Action\\Title')->getMock();
     $contextMock->expects($this->any())->method('getTitle')->willReturn($titleMock);
     $viewMock = $this->getMockBuilder('\\Magento\\Framework\\App\\ViewInterface')->getMock();
     $viewMock->expects($this->any())->method('loadLayout')->willReturnSelf();
     $contextMock->expects($this->any())->method('getView')->willReturn($viewMock);
     $contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactoryMock);
     $this->_customerAccountManagementMock = $this->getMockBuilder('Magento\\Customer\\Api\\AccountManagementInterface')->getMock();
     $this->_customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMock();
     $args = ['context' => $contextMock, 'customerAccountManagement' => $this->_customerAccountManagementMock, 'customerRepository' => $this->_customerRepositoryMock];
     $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_testedObject = $helperObjectManager->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\ResetPassword', $args);
 }
Example #22
0
 /**
  * Run test execute method
  *
  * @param int|bool $categoryId
  * @param int $storeId
  * @param int|null $parentId
  * @return void
  *
  * @dataProvider dataProviderExecute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecute($categoryId, $storeId, $parentId)
 {
     $rootCategoryId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
     $products = [['any_product']];
     $postData = ['general-data', 'parent' => $parentId, 'category_products' => json_encode($products)];
     if (isset($storeId)) {
         $postData['store_id'] = $storeId;
     }
     /**
      * @var \Magento\Backend\Model\View\Result\Redirect
      * |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
      */
     $resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     /**
      * @var \Magento\Framework\View\Element\Messages
      * |\PHPUnit_Framework_MockObject_MockObject $blockMock
      */
     $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\Messages', ['setMessages', 'getGroupedHtml'], [], '', false);
     /**
      * @var \Magento\Catalog\Model\Category
      * |\PHPUnit_Framework_MockObject_MockObject $categoryMock
      */
     $categoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', ['setStoreId', 'load', 'getPath', 'getResource', 'setPath', 'setParentId', 'setData', 'addData', 'setAttributeSetId', 'getDefaultAttributeSetId', 'getProductsReadonly', 'setPostedProducts', 'getId', 'validate', 'unsetData', 'save', 'toArray'], [], '', false);
     /**
      * @var \Magento\Catalog\Model\Category
      * |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock
      */
     $parentCategoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', ['setStoreId', 'load', 'getPath', 'setPath', 'setParentId', 'setData', 'addData', 'setAttributeSetId', 'getDefaultAttributeSetId', 'getProductsReadonly', 'setPostedProducts', 'getId'], [], '', false);
     /**
      * @var \Magento\Backend\Model\Auth\Session
      * |\PHPUnit_Framework_MockObject_MockObject $sessionMock
      */
     $sessionMock = $this->getMock('Magento\\Backend\\Model\\Auth\\Session', [], [], '', false);
     /**
      * @var \Magento\Framework\Registry
      * |\PHPUnit_Framework_MockObject_MockObject $registryMock
      */
     $registryMock = $this->getMock('Magento\\Framework\\Registry', ['register'], [], '', false);
     /**
      * @var \Magento\Cms\Model\Wysiwyg\Config
      * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
      */
     $wysiwygConfigMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Config', ['setStoreId'], [], '', false);
     /**
      * @var \Magento\Store\Model\StoreManagerInterface
      * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
      */
     $storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface', [], '', false, true, true, ['getStore', 'getRootCategoryId']);
     /**
      * @var \Magento\Framework\View\Layout
      * |\PHPUnit_Framework_MockObject_MockObject $layoutMock
      */
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Layout', [], '', false, true, true, ['getMessagesBlock']);
     /**
      * @var \Magento\Framework\Controller\Result\Json
      * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
      */
     $resultJsonMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Config', ['setData'], [], '', false);
     /**
      * @var \Magento\Framework\Message\Collection
      * |\PHPUnit_Framework_MockObject_MockObject $messagesMock
      */
     $messagesMock = $this->getMock('Magento\\Framework\\Message\\Collection', [], [], '', false);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRedirectMock));
     $this->requestMock->expects($this->atLeastOnce())->method('getParam')->will($this->returnValueMap([['id', false, $categoryId], ['store', null, $storeId], ['parent', null, $parentId]]));
     $this->objectManagerMock->expects($this->atLeastOnce())->method('create')->will($this->returnValue($categoryMock));
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap([['Magento\\Backend\\Model\\Auth\\Session', $sessionMock], ['Magento\\Framework\\Registry', $registryMock], ['Magento\\Cms\\Model\\Wysiwyg\\Config', $wysiwygConfigMock], ['Magento\\Store\\Model\\StoreManagerInterface', $storeManagerMock]]));
     $categoryMock->expects($this->once())->method('setStoreId')->with($storeId);
     $registryMock->expects($this->any())->method('register')->will($this->returnValueMap([['category', $categoryMock], ['current_category', $categoryMock]]));
     $wysiwygConfigMock->expects($this->once())->method('setStoreId')->with($storeId);
     $this->requestMock->expects($this->atLeastOnce())->method('getPost')->will($this->returnValueMap([['use_config', ['attribute']], ['use_default', ['default-attribute']], ['return_session_messages_only', true]]));
     $this->requestMock->expects($this->atLeastOnce())->method('getPostValue')->willReturn($postData);
     $categoryMock->expects($this->once())->method('addData')->with($postData);
     $categoryMock->expects($this->at(0))->method('getId')->will($this->returnValue($categoryId));
     if (!$parentId) {
         if ($storeId) {
             $storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnSelf());
             $storeManagerMock->expects($this->once())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
             $parentId = $rootCategoryId;
         }
     }
     $categoryMock->expects($this->any())->method('load')->will($this->returnValue($parentCategoryMock));
     $parentCategoryMock->expects($this->once())->method('getPath')->will($this->returnValue('parent_category_path'));
     $categoryMock->expects($this->once())->method('setPath')->with('parent_category_path');
     $categoryMock->expects($this->once())->method('setParentId')->with($parentId);
     $categoryMock->expects($this->atLeastOnce())->method('setData')->will($this->returnValueMap([['attribute', null, true], ['default-attribute', false, true], ['use_post_data_config', ['attribute'], true]]));
     $categoryMock->expects($this->once())->method('getDefaultAttributeSetId')->will($this->returnValue('default-attribute'));
     $categoryMock->expects($this->once())->method('setAttributeSetId')->with('default-attribute');
     $categoryMock->expects($this->once())->method('getProductsReadonly')->will($this->returnValue(false));
     $categoryMock->expects($this->once())->method('setPostedProducts')->with($products);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('catalog_category_prepare_save', ['category' => $categoryMock, 'request' => $this->requestMock]);
     $categoryResource = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Category', [], [], '', false);
     $categoryMock->expects($this->once())->method('getResource')->will($this->returnValue($categoryResource));
     $categoryMock->expects($this->once())->method('validate')->will($this->returnValue(true));
     $categoryMock->expects($this->once())->method('unsetData')->with('use_post_data_config');
     $categoryMock->expects($this->once())->method('save');
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You saved the category.'));
     $categoryMock->expects($this->at(1))->method('getId')->will($this->returnValue(111));
     $this->layoutFactoryMock->expects($this->once())->method('create')->will($this->returnValue($layoutMock));
     $layoutMock->expects($this->once())->method('getMessagesBlock')->will($this->returnValue($blockMock));
     $this->messageManagerMock->expects($this->once())->method('getMessages')->with(true)->will($this->returnValue($messagesMock));
     $blockMock->expects($this->once())->method('setMessages')->with($messagesMock);
     $blockMock->expects($this->once())->method('getGroupedHtml')->will($this->returnValue('grouped-html'));
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultJsonMock));
     $categoryMock->expects($this->once())->method('toArray')->will($this->returnValue(['category-data']));
     $resultJsonMock->expects($this->once())->method('setData')->with(['messages' => 'grouped-html', 'error' => false, 'category' => ['category-data']])->will($this->returnValue('result-execute'));
     $this->assertEquals('result-execute', $this->save->execute());
 }
Example #23
0
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteWithNewCustomerAndException()
 {
     $subscription = 'false';
     $postValue = ['customer' => ['coolness' => false, 'disable_auto_group_change' => 'false'], 'subscription' => $subscription];
     $filteredData = ['coolness' => false, 'disable_auto_group_change' => 'false'];
     /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $attributeMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface')->disableOriginalConstructor()->getMock();
     $attributeMock->expects($this->once())->method('getAttributeCode')->willReturn('coolness');
     $attributeMock->expects($this->once())->method('getFrontendInput')->willReturn('int');
     $attributes = [$attributeMock];
     $this->requestMock->expects($this->exactly(2))->method('getPostValue')->willReturn($postValue);
     $this->requestMock->expects($this->exactly(2))->method('getPost')->willReturnMap([['customer', null, $postValue['customer']], ['address', null, null]]);
     /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */
     $formMock = $this->getMockBuilder('Magento\\Customer\\Model\\Metadata\\Form')->disableOriginalConstructor()->getMock();
     $this->formFactoryMock->expects($this->once())->method('create')->with(\Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'adminhtml_customer', [], false, \Magento\Customer\Model\Metadata\Form::DONT_IGNORE_INVISIBLE)->willReturn($formMock);
     $formMock->expects($this->once())->method('extractData')->with($this->requestMock, 'customer')->willReturn($filteredData);
     /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */
     $objectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $this->objectFactoryMock->expects($this->once())->method('create')->with(['data' => $postValue])->willReturn($objectMock);
     $objectMock->expects($this->once())->method('getData')->with('customer')->willReturn($postValue['customer']);
     $formMock->expects($this->once())->method('getAttributes')->willReturn($attributes);
     /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerDataFactoryMock->expects($this->once())->method('create')->willReturn($customerMock);
     $exception = new \Exception(__('Exception'));
     $this->managementMock->expects($this->once())->method('createAccount')->with($customerMock, null, '')->willThrowException($exception);
     $customerMock->expects($this->never())->method('getId');
     $this->authorizationMock->expects($this->never())->method('isAllowed');
     $this->subscriberFactoryMock->expects($this->never())->method('create');
     $this->sessionMock->expects($this->never())->method('unsCustomerData');
     $this->registryMock->expects($this->never())->method('register');
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->messageManagerMock->expects($this->once())->method('addException')->with($exception, __('Something went wrong while saving the customer.'));
     $this->sessionMock->expects($this->once())->method('setCustomerData')->with($postValue);
     /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->redirectFactoryMock->expects($this->once())->method('create')->with([])->willReturn($redirectMock);
     $redirectMock->expects($this->once())->method('setPath')->with('customer/*/new', ['_current' => true])->willReturn(true);
     $this->assertEquals($redirectMock, $this->model->execute());
 }
Example #24
0
 protected function prepareRedirect()
 {
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
 }