Ejemplo n.º 1
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', 'getResultFactory'], [], '', 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->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->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('getResultFactory')->willReturn($this->resultFactory);
     $this->shipmentEmail = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\Email', ['context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response]);
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', [], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', [], [], '', false);
     $this->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->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $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('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->invoiceEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Invoice\\Email', ['context' => $this->context, 'resultForwardFactory' => $this->resultForwardFactory]);
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->customerCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
     $this->customerCollectionFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->subscriberMock = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriberFactoryMock = $this->getMockBuilder('Magento\\Newsletter\\Model\\SubscriberFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $subscriberFactoryMock->expects($this->any())->method('create')->willReturn($this->subscriberMock);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->customerCollectionMock)->willReturnArgument(0);
     $this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->customerCollectionMock);
     $this->customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMockForAbstractClass();
     $this->massAction = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\MassUnsubscribe', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->customerCollectionFactoryMock, 'customerRepository' => $this->customerRepositoryMock, 'subscriberFactory' => $subscriberFactoryMock]);
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory', 'getResultFactory'], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\Resource\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassCancel', ['context' => $this->contextMock]);
 }
Ejemplo n.º 5
0
 protected function setUp()
 {
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse']);
     $this->redirect = $this->getMock('\\Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirect));
     $this->unit = (new ObjectManager($this))->getObject('Magento\\Store\\Controller\\Store\\SwitchAction', ['context' => $this->context]);
 }
Ejemplo n.º 6
0
 /**
  * Run test for execute method (exception)
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Wrong type of request.
  */
 public function testExecuteException()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects(static::once())->method('getRequest')->willReturn($this->getRequestMock(false));
     $this->checkoutSessionMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock->expects(static::never())->method('getQuote');
     $getButtonData = new GetButtonData($this->contextMock, $this->checkoutSessionMock);
     $getButtonData->execute();
 }
Ejemplo n.º 7
0
 public function setUp()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->getMock();
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->redirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->setMethods(['setRefererOrBaseUrl'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory->expects($this->any())->method('create')->willReturn($this->redirect);
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->redirectFactory);
     $this->action = $this->getMockForAbstractClass('Magento\\Framework\\App\\Action\\AbstractAction', [$this->context]);
 }
Ejemplo n.º 8
0
 protected function setUp()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->getMockForAbstractClass();
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->response = $this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->getMockForAbstractClass();
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->getMock();
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectManager->getObject('\\Magento\\SampleServiceContractClient\\Controller\\Index\\Index', ['context' => $this->context, 'resultPageFactory' => $this->resultPageFactory]);
 }
Ejemplo n.º 9
0
 protected function setUp()
 {
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['getPostValue'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->viewMock = $this->getMockBuilder('Magento\\Framework\\App\\ViewInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->coreRegistryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['register'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->setMethods(['addDefaultHandle', 'getLayout', 'getUpdate', 'load'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\LayoutFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($this->resultLayoutMock);
     $this->transactionMock = $this->getMockBuilder('Magento\\Paypal\\Model\\Payflow\\Service\\Response\\Transaction')->setMethods(['getResponseObject', 'validateResponse', 'savePaymentInQuote'])->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('\\Magento\\Framework\\App\\Action\\Context')->setMethods(['getRequest'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->responseValidatorMock = $this->getMockBuilder('Magento\\Paypal\\Model\\Payflow\\Service\\Response\\Validator\\ResponseValidator')->disableOriginalConstructor()->getMock();
     $this->object = new Response($this->contextMock, $this->coreRegistryMock, $this->transactionMock, $this->responseValidatorMock, $this->resultLayoutFactoryMock);
 }
Ejemplo n.º 10
0
 protected function prepareContext()
 {
     $eventManager = $this->getMock('Magento\\Framework\\Event\\Manager', null, [], '', false);
     $actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->context->expects($this->any())->method('getObjectManager')->willReturn($this->om);
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->any())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->any())->method('getEventManager')->willReturn($eventManager);
     $this->context->expects($this->any())->method('getUrl')->willReturn($this->url);
     $this->context->expects($this->any())->method('getActionFlag')->willReturn($actionFlag);
     $this->context->expects($this->any())->method('getRedirect')->willReturn($this->redirect);
     $this->context->expects($this->any())->method('getView')->willReturn($this->view);
     $this->context->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager);
 }
Ejemplo n.º 11
0
 protected function setUp()
 {
     $this->customerSessionMock = $this->getMock('\\Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', ['setRedirect', '__wakeup'], [], '', false);
     $viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->urlMock = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $urlFactoryMock = $this->getMock('Magento\\Framework\\UrlFactory', [], [], '', false);
     $urlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->urlMock));
     $this->customerAccountManagementMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface');
     $this->customerDataMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerRepositoryMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->addressHelperMock = $this->getMock('Magento\\Customer\\Helper\\Address', [], [], '', false);
     $this->storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->redirectResultMock = $this->getMock('Magento\\Framework\\Controller\\Result\\Redirect', [], [], '', false);
     $resultFactoryMock = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $resultFactoryMock->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($this->redirectResultMock);
     $this->scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->contextMock = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->any())->method('getRedirect')->willReturn($this->redirectMock);
     $this->contextMock->expects($this->any())->method('getView')->willReturn($viewMock);
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->model = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Account\\Confirm', ['context' => $this->contextMock, 'customerSession' => $this->customerSessionMock, 'scopeConfig' => $this->scopeConfigMock, 'storeManager' => $this->storeManagerMock, 'customerAccountManagement' => $this->customerAccountManagementMock, 'customerRepository' => $this->customerRepositoryMock, 'addressHelper' => $this->addressHelperMock, 'urlFactory' => $urlFactoryMock]);
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory'], [], '', false);
     $this->orderManagementMock = $this->getMockBuilder('Magento\\Sales\\Api\\OrderManagementInterface')->getMockForAbstractClass();
     $this->orderRepositoryMock = $this->getMockBuilder('Magento\\Sales\\Api\\OrderRepositoryInterface')->getMockForAbstractClass();
     $this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMockForAbstractClass();
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->orderMock = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderInterface')->getMockForAbstractClass();
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->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($resultRedirectFactory);
     $this->orderEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Email', ['context' => $this->context, 'request' => $this->request, 'response' => $this->response, 'orderManagement' => $this->orderManagementMock, 'orderRepository' => $this->orderRepositoryMock, 'logger' => $this->loggerMock]);
 }
Ejemplo n.º 13
0
 protected function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->orderManagementMock = $this->getMockBuilder('Magento\\Sales\\Api\\OrderManagementInterface')->getMockForAbstractClass();
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $orderCollection = 'Magento\\Sales\\Model\\ResourceModel\\Order\\CollectionFactory';
     $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->orderCollectionMock)->willReturn($this->orderCollectionMock);
     $this->orderCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->orderCollectionMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassHold', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->orderCollectionFactoryMock, 'orderManagement' => $this->orderManagementMock]);
 }
Ejemplo n.º 14
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->wishlistProviderMock = $this->getMockBuilder('Magento\\Wishlist\\Controller\\WishlistProviderInterface')->disableOriginalConstructor()->setMethods(['getWishlist'])->getMockForAbstractClass();
     $this->quantityProcessorMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\LocaleQuantityProcessor')->disableOriginalConstructor()->getMock();
     $this->itemFactoryMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\ItemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->checkoutCartMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Cart')->disableOriginalConstructor()->setMethods(['save', 'getQuote', 'getShouldRedirectToCart', 'getCartUrl'])->getMock();
     $this->optionFactoryMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\OptionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productHelperMock = $this->getMockBuilder('Magento\\Catalog\\Helper\\Product')->disableOriginalConstructor()->getMock();
     $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
     $this->helperMock = $this->getMockBuilder('Magento\\Wishlist\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getParams', 'getParam', 'isAjax'])->getMockForAbstractClass();
     $this->redirectMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\RedirectInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->messageManagerMock = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->disableOriginalConstructor()->setMethods(['addSuccess'])->getMockForAbstractClass();
     $this->urlMock = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->disableOriginalConstructor()->setMethods(['getUrl'])->getMockForAbstractClass();
     $this->cartHelperMock = $this->getMockBuilder('Magento\\Checkout\\Helper\\Cart')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->contextMock->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirectMock));
     $this->contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $this->contextMock->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->messageManagerMock));
     $this->contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
     $this->resultFactoryMock->expects($this->any())->method('create')->willReturnMap([[ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock], [ResultFactory::TYPE_JSON, [], $this->resultJsonMock]]);
     $this->model = new Cart($this->contextMock, $this->wishlistProviderMock, $this->quantityProcessorMock, $this->itemFactoryMock, $this->checkoutCartMock, $this->optionFactoryMock, $this->productHelperMock, $this->escaperMock, $this->helperMock, $this->cartHelperMock);
 }
Ejemplo n.º 15
0
    /**
     * Prepare context
     *
     * @return void
     */
    public function prepareContext()
    {
        $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false);

        $this->context
            ->expects($this->any())
            ->method('getObjectManager')
            ->willReturn($this->om);
        $this->context
            ->expects($this->any())
            ->method('getRequest')
            ->willReturn($this->request);
        $this->context
            ->expects($this->any())
            ->method('getEventManager')
            ->willReturn($this->eventManager);
        $this->context
            ->expects($this->any())
            ->method('getUrl')
            ->willReturn($this->url);
        $this->context
            ->expects($this->any())
            ->method('getActionFlag')
            ->willReturn($actionFlag);
        $this->context
            ->expects($this->any())
            ->method('getMessageManager')
            ->willReturn($this->messageManager);
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);
    }
Ejemplo n.º 16
0
 /**
  * Set up before test
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_installerMock = $this->getMock('\\Magento\\Install\\Model\\Installer', array('isApplicationInstalled'), array(), '', false);
     $this->_installerMock->expects($this->any())->method('isApplicationInstalled')->will($this->returnValue(true));
     $this->_blockMock = $this->getMock('\\Magento\\Install\\Block\\Locale', array(), array(), '', false);
     $this->_layoutMock = $this->getMock('\\Magento\\Framework\\View\\Layout', array('getBlock', 'initMessages', 'addBlock'), array(), '', false);
     $this->_layoutMock->expects($this->any())->method('initMessages')->withAnyParameters()->will($this->returnValue(true));
     $this->_layoutMock->expects($this->any())->method('addBlock')->withAnyParameters()->will($this->returnValue(true));
     $this->_viewMock = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\ViewInterface', array(), '', false, false, true, array('getLayout'));
     $this->_viewMock->expects($this->any())->method('getLayout')->withAnyParameters()->will($this->returnValue($this->_layoutMock));
     $this->_requestMock = $this->_getClearMock('\\Magento\\Framework\\App\\RequestInterface');
     $this->_responseMock = $this->_getClearMock('\\Magento\\Framework\\App\\ResponseInterface');
     $this->_actionFlagMock = $this->_getClearMock('\\Magento\\Framework\\App\\ActionFlag');
     $this->_contextMock = $this->getMock('\\Magento\\Framework\\App\\Action\\Context', array('getView', 'getRequest', 'getResponse', 'getActionFlag'), array(), '', false);
     $this->_contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->_viewMock));
     $this->_contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->_requestMock));
     $this->_contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->_responseMock));
     $this->_contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->_actionFlagMock));
     $this->_blockContextMock = $this->getMock('\\Magento\\Framework\\View\\Element\\Template\\Context', array(), array(), '', false);
     $this->_wizardMock = $this->getMock('\\Magento\\Install\\Model\\Wizard', array('getStepByRequest'), array(), '', false);
     $this->_wizardMock->expects($this->any())->method('getStepByRequest')->withAnyParameters()->will($this->returnValue(false));
     $this->_sessionMock = $this->getMock('\\Magento\\Framework\\Session\\Generic', array('getLocale'), array(), '', false);
     $this->_sessionMock->expects($this->any())->method('getLocale')->will($this->returnValue(self::LOCALE));
     $this->_block = $this->_objectManager->getObject('Magento\\Install\\Block\\Locale', array('context' => $this->_blockContextMock, 'installer' => $this->_installerMock, 'installWizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'data' => array()));
     $this->_layoutMock->expects($this->any())->method('getBlock')->with('install.locale')->will($this->returnValue($this->_block));
     $this->_controller = $this->_objectManager->getObject('Magento\\Install\\Controller\\Wizard\\Locale', array('context' => $this->_contextMock, 'configScope' => $this->_getClearMock('Magento\\Framework\\Config\\Scope'), 'installer' => $this->_getClearMock('Magento\\Install\\Model\\Installer'), 'wizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'dbUpdater' => $this->_getClearMock('Magento\\Framework\\Module\\UpdaterInterface'), 'storeManager' => $this->_getClearMock('Magento\\Store\\Model\\StoreManagerInterface'), 'appState' => $this->_getClearMock('Magento\\Framework\\App\\State')));
 }
Ejemplo n.º 17
0
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $this->blockMock = $this->getMockBuilder('\\Magento\\Checkout\\Block\\Onepage\\Success')->disableOriginalConstructor()->getMock();
     $this->orderFactoryMock = $this->getMock('\\Magento\\Sales\\Model\\OrderFactory', ['create'], [], '', false);
     $this->payflowlinkFactoryMock = $this->getMock('\\Magento\\Paypal\\Model\\PayflowlinkFactory', [], [], '', false);
     $this->helperCheckoutMock = $this->getMock('\\Magento\\Paypal\\Helper\\Checkout', [], [], '', false);
     $this->loggerMock = $this->getMockForAbstractClass('\\Psr\\Log\\LoggerInterface');
     $this->orderMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock = $this->getMockBuilder('\\Magento\\Checkout\\Model\\Session')->setMethods(['getLastRealOrderId', 'getLastRealOrder', 'restoreQuote'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->once())->method('getView')->will($this->returnValue($this->viewMock));
     $this->contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->returnUrl = new ReturnUrl($this->contextMock, $this->checkoutSessionMock, $this->orderFactoryMock, $this->payflowlinkFactoryMock, $this->helperCheckoutMock, $this->loggerMock);
 }
Ejemplo n.º 18
0
 protected function prepareContext()
 {
     $om = $this->getMock('Magento\\Framework\\App\\ObjectManager', [], [], '', false);
     $eventManager = $this->getMock('Magento\\Framework\\Event\\Manager', null, [], '', false);
     $url = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $redirect = $this->getMock('\\Magento\\Store\\App\\Response\\Redirect', [], [], '', false);
     $view = $this->getMock('Magento\\Framework\\App\\View', [], [], '', false);
     $messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($om));
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
     $this->context->expects($this->any())->method('getUrl')->will($this->returnValue($url));
     $this->context->expects($this->any())->method('getActionFlag')->will($this->returnValue($actionFlag));
     $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($view));
     $this->context->expects($this->any())->method('getMessageManager')->will($this->returnValue($messageManager));
 }
Ejemplo n.º 19
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteProductAddedToWishlistAfterObjectManagerThrowException()
 {
     $product = $this->getMock('Magento\\Catalog\\Model\\Product', ['isVisibleInCatalog', 'getName'], [], '', false);
     $product->expects($this->once())->method('isVisibleInCatalog')->will($this->returnValue(true));
     $product->expects($this->once())->method('getName')->will($this->returnValue('Product test name'));
     $this->productRepository->expects($this->once())->method('getById')->with(2)->will($this->returnValue($product));
     $exception = new \Exception('Exception');
     $wishListItem = new \stdClass();
     $wishlist = $this->getMock('Magento\\Wishlist\\Model\\Wishlist', ['addNewItem', 'save', 'getId'], [], '', false);
     $wishlist->expects($this->once())->method('addNewItem')->will($this->returnValue($wishListItem));
     $wishlist->expects($this->once())->method('getId')->will($this->returnValue(2));
     $wishlist->expects($this->once())->method('save')->will($this->returnValue(true));
     $this->wishlistProvider->expects($this->once())->method('getWishlist')->will($this->returnValue($wishlist));
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParams'], [], '', false);
     $request->expects($this->once())->method('getParams')->will($this->returnValue(['product' => 2]));
     $wishlistHelper = $this->getMock('Magento\\Wishlist\\Helper\\Data', ['calculate'], [], '', false);
     $wishlistHelper->expects($this->once())->method('calculate')->will($this->returnSelf());
     $escaper = $this->getMock('Magento\\Framework\\Escaper', ['escapeHtml', 'escapeUrl'], [], '', false);
     $escaper->expects($this->once())->method('escapeHtml')->with('Product test name')->will($this->returnValue('Product test name'));
     $escaper->expects($this->once())->method('escapeUrl')->with('http://test-url.com')->will($this->returnValue('http://test-url.com'));
     $logger = $this->getMock('Magento\\Framework\\Logger\\Monolog', ['critical'], [], '', false);
     $logger->expects($this->once())->method('critical')->with($exception)->will($this->returnValue(true));
     $om = $this->getMock('Magento\\Framework\\App\\ObjectManager', ['get'], [], '', false);
     $om->expects($this->at(0))->method('get')->with('Magento\\Wishlist\\Helper\\Data')->will($this->returnValue($wishlistHelper));
     $om->expects($this->at(1))->method('get')->with('Magento\\Framework\\Escaper')->will($this->returnValue($escaper));
     $om->expects($this->at(2))->method('get')->with('Magento\\Framework\\Escaper')->will($this->returnValue($escaper));
     $om->expects($this->at(3))->method('get')->with('Psr\\Log\\LoggerInterface')->will($this->returnValue($logger));
     $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', null, [], '', false);
     $eventManager = $this->getMock('Magento\\Framework\\Event\\Manager', ['dispatch'], [], '', false);
     $eventManager->expects($this->once())->method('dispatch')->with('wishlist_add_product', ['wishlist' => $wishlist, 'product' => $product, 'item' => $wishListItem])->will($this->returnValue(true));
     $url = $this->getMock('Magento\\Framework\\Url', null, [], '', false);
     $actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', null, [], '', false);
     $redirect = $this->getMock('\\Magento\\Store\\App\\Response\\Redirect', ['redirect'], [], '', false);
     $redirect->expects($this->once())->method('redirect')->with($response, '*', ['wishlist_id' => 2])->will($this->returnValue(null));
     $view = $this->getMock('Magento\\Framework\\App\\View', null, [], '', false);
     $messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addError', 'addSuccess'], [], '', false);
     $messageManager->expects($this->once())->method('addError')->with('An error occurred while adding item to wish list.')->will($this->returnValue(null));
     $messageManager->expects($this->once())->method('addSuccess')->will($this->throwException($exception));
     $this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($om));
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
     $this->context->expects($this->any())->method('getUrl')->will($this->returnValue($url));
     $this->context->expects($this->any())->method('getActionFlag')->will($this->returnValue($actionFlag));
     $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($view));
     $this->context->expects($this->any())->method('getMessageManager')->will($this->returnValue($messageManager));
     $this->customerSession->expects($this->exactly(1))->method('getBeforeWishlistRequest')->will($this->returnValue(false));
     $this->customerSession->expects($this->never())->method('unsBeforeWishlistRequest')->will($this->returnValue(null));
     $this->customerSession->expects($this->once())->method('getBeforeWishlistUrl')->will($this->returnValue('http://test-url.com'));
     $this->customerSession->expects($this->once())->method('setBeforeWishlistUrl')->with(null)->will($this->returnValue(null));
     $this->createController();
     $this->controller->execute();
 }
Ejemplo n.º 20
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess'], [], '', 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->context->expects($this->once())->method('getMessageManager')->will($this->returnValue($this->messageManager));
     $this->context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->once())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->once())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->once())->method('getSession')->will($this->returnValue($this->session));
     $this->context->expects($this->once())->method('getActionFlag')->will($this->returnValue($this->actionFlag));
     $this->context->expects($this->once())->method('getHelper')->will($this->returnValue($this->helper));
     $this->creditmemoEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Creditmemo\\AbstractCreditmemo\\Email', ['context' => $this->context, 'request' => $this->request, 'response' => $this->response]);
 }
Ejemplo n.º 21
0
 protected function setUp()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMockBuilder('Magento\\Customer\\Model\\Session')->disableOriginalConstructor()->setMethods(['getId', 'logout', 'setBeforeAuthUrl', 'setLastCustomerId'])->getMock();
     $this->cookieMetadataFactory = $this->getMockBuilder(CookieMetadataFactory::class)->disableOriginalConstructor()->getMock();
     $this->cookieManager = $this->getMockBuilder(PhpCookieManager::class)->disableOriginalConstructor()->getMock();
     $this->cookieMetadata = $this->getMockBuilder(CookieMetadata::class)->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder(RedirectFactory::class)->disableOriginalConstructor()->getMock();
     $this->resultRedirect = $this->getMockBuilder(Redirect::class)->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($this->redirectFactory);
     $this->redirect = $this->getMockBuilder(RedirectInterface::class)->getMockForAbstractClass();
     $this->contextMock->expects($this->once())->method('getRedirect')->willReturn($this->redirect);
     $this->controller = new Logout($this->contextMock, $this->sessionMock);
     $refClass = new \ReflectionClass(Logout::class);
     $cookieMetadataManagerProperty = $refClass->getProperty('cookieMetadataManager');
     $cookieMetadataManagerProperty->setAccessible(true);
     $cookieMetadataManagerProperty->setValue($this->controller, $this->cookieManager);
     $cookieMetadataFactoryProperty = $refClass->getProperty('cookieMetadataFactory');
     $cookieMetadataFactoryProperty->setAccessible(true);
     $cookieMetadataFactoryProperty->setValue($this->controller, $this->cookieMetadataFactory);
 }
Ejemplo n.º 22
0
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\App\\Action\\Context', ['getRequest', 'getResponse'], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->request);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->response);
     $this->itemFactoryMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Compare\\ItemFactory', [], [], '', false);
     $this->collectionFactoryMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Compare\\Item\\CollectionFactory', [], [], '', false);
     $this->sessionMock = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->visitorMock = $this->getMock('Magento\\Customer\\Model\\Visitor', [], [], '', false);
     $this->listCompareMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Compare\\ListCompare', [], [], '', false);
     $this->catalogSession = $this->getMock('Magento\\Catalog\\Model\\Session', ['setBeforeCompareUrl'], [], '', false);
     $this->storeManagerMock = $this->getMock('Magento\\Framework\\Store\\StoreManagerInterface');
     $this->formKeyValidatorMock = $this->getMock('Magento\\Core\\App\\Action\\FormKeyValidator', [], [], '', false);
     $this->redirectFactoryMock = $this->getMock('Magento\\Framework\\Controller\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->pageFactoryMock = $this->getMock('Magento\\Framework\\View\\Result\\PageFactory', [], [], '', false);
     $this->productRepositoryMock = $this->getMock('Magento\\Catalog\\Api\\ProductRepositoryInterface');
     $this->decoderMock = $this->getMock('Magento\\Framework\\Url\\DecoderInterface');
     $this->index = new Index($this->contextMock, $this->itemFactoryMock, $this->collectionFactoryMock, $this->sessionMock, $this->visitorMock, $this->listCompareMock, $this->catalogSession, $this->storeManagerMock, $this->formKeyValidatorMock, $this->redirectFactoryMock, $this->pageFactoryMock, $this->productRepositoryMock, $this->decoderMock);
 }
Ejemplo n.º 23
0
 protected function prepareContext()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultRedirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->messageManager = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->getMockForAbstractClass();
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager);
     $this->eventManager = $this->getMockBuilder('Magento\\Framework\\Event\\ManagerInterface')->getMockForAbstractClass();
     $this->context->expects($this->any())->method('getEventManager')->willReturn($this->eventManager);
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
 }
Ejemplo n.º 24
0
 protected function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $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\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess'], [], '', 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->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->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->resultRedirectFactoryMock);
     $this->creditmemoEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Creditmemo\\AbstractCreditmemo\\Email', ['context' => $this->context]);
 }
Ejemplo n.º 25
0
    protected function prepareContext()
    {
        $om = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false);
        $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false);
        $url = $this->getMock('Magento\Framework\Url', [], [], '', false);
        $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false);
        $messageManager = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false);

        $this->context
            ->expects($this->any())
            ->method('getObjectManager')
            ->willReturn($om);
        $this->context
            ->expects($this->any())
            ->method('getRequest')
            ->willReturn($this->request);
        $this->context
            ->expects($this->any())
            ->method('getResponse')
            ->willReturn($this->response);
        $this->context
            ->expects($this->any())
            ->method('getEventManager')
            ->willReturn($eventManager);
        $this->context
            ->expects($this->any())
            ->method('getUrl')
            ->willReturn($url);
        $this->context
            ->expects($this->any())
            ->method('getActionFlag')
            ->willReturn($actionFlag);
        $this->context
            ->expects($this->any())
            ->method('getRedirect')
            ->willReturn($this->redirect);
        $this->context
            ->expects($this->any())
            ->method('getMessageManager')
            ->willReturn($messageManager);
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);
    }
Ejemplo n.º 26
0
 protected function setUp()
 {
     $this->contextMock = $this->getMock(Context::class, [], [], '', false);
     $this->viewMock = $this->getMock(ViewInterface::class);
     $this->requestMock = $this->getMock(Http::class, ['getParam'], [], '', false);
     $this->layoutMock = $this->getMock(LayoutInterface::class);
     $this->blockMock = $this->getMockBuilder(Success::class)->disableOriginalConstructor()->getMock();
     $this->orderFactoryMock = $this->getMock(OrderFactory::class, ['create'], [], '', false);
     $this->payflowlinkFactoryMock = $this->getMock(PayflowlinkFactory::class, [], [], '', false);
     $this->helperCheckoutMock = $this->getMock(Checkout::class, ['cancelCurrentOrder'], [], '', false);
     $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
     $this->orderMock = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
     $this->paymentMock = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock();
     $this->orderMock->expects($this->any())->method('getPayment')->will($this->returnValue($this->paymentMock));
     $this->checkoutSessionMock = $this->getMockBuilder(Session::class)->setMethods(['getLastRealOrderId', 'getLastRealOrder', 'restoreQuote'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
     $this->contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->returnUrl = new ReturnUrl($this->contextMock, $this->checkoutSessionMock, $this->orderFactoryMock, $this->payflowlinkFactoryMock, $this->helperCheckoutMock, $this->loggerMock);
 }
Ejemplo n.º 27
0
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->orderRepositoryMock = $this->getMockBuilder('Magento\\Sales\\Api\\OrderRepositoryInterface')->disableOriginalConstructor()->getMock();
     $this->validatorMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\FormKey\\Validator')->disableOriginalConstructor()->getMock();
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->any())->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('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->context->expects($this->once())->method('getFormKeyValidator')->willReturn($this->validatorMock);
     $this->controller = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Cancel', ['context' => $this->context, 'request' => $this->request, 'response' => $this->response, 'orderRepository' => $this->orderRepositoryMock]);
 }