本文整理汇总了PHP中Magento\Framework\App\Action\Context::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::expects方法的具体用法?PHP Context::expects怎么用?PHP Context::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Action\Context
的用法示例。
在下文中一共展示了Context::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
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]);
}
示例2: setUp
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]);
}
示例3: setUp
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]);
}
示例4: setUp
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]);
}
示例5: setUp
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]);
}
示例6: testExecuteException
/**
* 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();
}
示例7: setUp
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]);
}
示例8: setUp
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]);
}
示例9: setUp
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);
}
示例10: prepareContext
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);
}
示例11: setUp
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]);
}
示例12: setUp
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]);
}
示例13: setUp
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]);
}
示例14: setUp
/**
* @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);
}
示例15: prepareContext
/**
* 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);
}