本文整理汇总了PHP中Magento\Backend\App\Action\Context::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::expects方法的具体用法?PHP Context::expects怎么用?PHP Context::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\App\Action\Context
的用法示例。
在下文中一共展示了Context::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Init mocks for tests
* @return void
*/
public function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
$this->viewMock = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
$this->contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
$this->controller = $this->objectManager->getObject('\\Magento\\Security\\Controller\\Adminhtml\\Session\\Activity', ['context' => $this->contextMock]);
}
示例2: setUp
public function setUp()
{
$this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
$this->resultFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultPage = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultInterface')->setMethods(['setData'])->getMockForAbstractClass();
$this->imageProcessor = $this->getMockBuilder('Magento\\Theme\\Model\\Design\\Config\\FileUploader\\ImageProcessor')->disableOriginalConstructor()->getMock();
$this->context->expects($this->once())->method('getResultFactory')->willReturn($this->resultFactory);
$this->controller = new Save($this->context, $this->imageProcessor);
}
示例3: initContext
protected function initContext()
{
$this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
$this->resultRedirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$resultRedirectFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
$resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
$this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
}
示例4: setUp
protected function setUp()
{
$this->autocomplete = $this->getMockBuilder('Magento\Search\Model\AutocompleteInterface')
->disableOriginalConstructor()
->setMethods(['getItems'])
->getMockForAbstractClass();
$this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
$this->url = $this->getMockBuilder('Magento\Framework\UrlInterface')
->disableOriginalConstructor()
->setMethods(['getBaseUrl'])
->getMockForAbstractClass();
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
->disableOriginalConstructor()
->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
->disableOriginalConstructor()
->getMock();
$this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
->disableOriginalConstructor()
->getMock();
$this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context')
->disableOriginalConstructor()
->getMock();
$this->context->expects($this->atLeastOnce())
->method('getRequest')
->will($this->returnValue($this->request));
$this->context->expects($this->any())
->method('getUrl')
->will($this->returnValue($this->url));
$this->context->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->objectManagerHelper = new ObjectManagerHelper($this);
$this->controller = $this->objectManagerHelper->getObject(
'Magento\Search\Controller\Ajax\Suggest',
[
'context' => $this->context,
'autocomplete' => $this->autocomplete
]
);
}
示例5: setUp
/**
* Set up
*/
protected function setUp()
{
$this->resultPage = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', false);
$this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf();
$this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf();
$this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
$this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
$this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getResultFactory'], [], '', false);
$this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->indexController = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Controller\\Adminhtml\\History\\Index', ['context' => $this->context]);
}
示例6: setUp
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->context = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
$this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->response = $this->getMock('\\Magento\\Framework\\App\\ResponseInterface', ['sendResponse', 'setBody']);
$this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
$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('getView')->will($this->returnValue($this->view));
$this->controller = $this->objectManagerHelper->getObject('\\Magento\\Bundle\\Controller\\Adminhtml\\Bundle\\Selection\\Grid', ['context' => $this->context]);
}
示例7: setUp
protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
$this->contextMock = $this->getMock('\\Magento\\Backend\\App\\Action\\Context', [], [], '', false);
$this->filterMock = $this->getMockBuilder('Magento\\Ui\\Component\\MassAction\\Filter')->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
$this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
}
示例8: setUp
protected function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$this->attributeLabelCacheMock = $this->getMockBuilder(FrontendInterface::class)->getMockForAbstractClass();
$this->coreRegistryMock = $this->getMockBuilder(Registry::class)->disableOriginalConstructor()->getMock();
$this->resultPageFactoryMock = $this->getMockBuilder(PageFactory::class)->disableOriginalConstructor()->getMock();
$this->requestMock = $this->getMockBuilder(RequestInterface::class)->setMethods(['getPostValue', 'has'])->getMockForAbstractClass();
$this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
$this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
}
示例9: setUp
protected function setUp()
{
$this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
$this->objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface')
->disableOriginalConstructor()
->setMethods(['create'])
->getMockForAbstractClass();
$this->messageManager = $this->getMockBuilder('\Magento\Framework\Message\ManagerInterface')
->disableOriginalConstructor()
->setMethods(['addSuccess', 'addError'])
->getMockForAbstractClass();
$this->pageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
->setMethods([])
->disableOriginalConstructor()
->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
->disableOriginalConstructor()
->getMock();
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
->disableOriginalConstructor()
->getMock();
$this->resultFactoryMock->expects($this->any())
->method('create')
->with(ResultFactory::TYPE_REDIRECT, [])
->willReturn($this->resultRedirectMock);
$this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context')
->disableOriginalConstructor()
->getMock();
$this->context->expects($this->atLeastOnce())
->method('getRequest')
->willReturn($this->request);
$this->context->expects($this->any())
->method('getObjectManager')
->willReturn($this->objectManager);
$this->context->expects($this->any())
->method('getMessageManager')
->willReturn($this->messageManager);
$this->context->expects($this->any())
->method('getResultFactory')
->willReturn($this->resultFactoryMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->controller = $this->objectManagerHelper->getObject(
'Magento\Search\Controller\Adminhtml\Term\MassDelete',
[
'context' => $this->context,
'resultPageFactory' => $this->pageFactory,
]
);
}
示例10: setUp
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->context = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
$this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->response = $this->getMock('\\Magento\\Framework\\App\\ResponseInterface', ['sendResponse', 'setBody']);
$this->productBuilder = $this->getMockBuilder('\\Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder')->disableOriginalConstructor()->setMethods(['build'])->getMock();
$this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
$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('getView')->will($this->returnValue($this->view));
$this->controller = $this->objectManagerHelper->getObject('\\Magento\\ConfigurableProduct\\Controller\\Adminhtml\\Product\\AddAttribute', ['context' => $this->context, 'productBuilder' => $this->productBuilder]);
}
示例11: setUp
protected function setUp()
{
$this->autocomplete = $this->getMockBuilder('Magento\\Search\\Model\\AutocompleteInterface')->disableOriginalConstructor()->setMethods(['getItems'])->getMockForAbstractClass();
$this->request = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods([])->getMockForAbstractClass();
$this->response = $this->getMockBuilder('\\Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->setMethods(['representJson', 'setRedirect'])->getMockForAbstractClass();
$this->url = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->disableOriginalConstructor()->setMethods(['getBaseUrl'])->getMockForAbstractClass();
$this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->setMethods(['getRequest', 'getResponse', 'getUrl'])->disableOriginalConstructor()->getMock();
$this->context->expects($this->atLeastOnce())->method('getRequest')->will($this->returnValue($this->request));
$this->context->expects($this->atLeastOnce())->method('getResponse')->will($this->returnValue($this->response));
$this->context->expects($this->any())->method('getUrl')->will($this->returnValue($this->url));
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->controller = $this->objectManagerHelper->getObject('Magento\\Search\\Controller\\Ajax\\Suggest', ['context' => $this->context, 'autocomplete' => $this->autocomplete]);
}
示例12: prepareContext
private function prepareContext()
{
$this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->setMethods(['getParam', 'getParams', 'setParams'])->disableOriginalConstructor()->getMock();
$objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->setMethods(['isProductsHasSku'])->disableOriginalConstructor()->getMock();
$product->expects($this->any())->method('isProductsHasSku')->with([1, 2, 3])->willReturn(true);
$objectManager->expects($this->any())->method('create')->with('Magento\\Catalog\\Model\\Product')->willReturn($product);
$messageManager = $this->getMockBuilder('\\Magento\\Framework\\Message\\ManagerInterface')->setMethods([])->disableOriginalConstructor()->getMock();
$messageManager->expects($this->any())->method('addError')->willReturn(true);
$this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getRequest', 'getObjectManager', 'getMessageManager', 'getResultRedirectFactory'])->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
$this->context->expects($this->any())->method('getObjectManager')->willReturn($objectManager);
$this->context->expects($this->any())->method('getMessageManager')->willReturn($messageManager);
$this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
}
示例13: setUp
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)->disableOriginalConstructor()->getMock();
$this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class);
$this->resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false);
$this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class, ['sendResponse', 'setBody']);
$this->productBuilder = $this->getMockBuilder(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class)->disableOriginalConstructor()->setMethods(['build'])->getMock();
$this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class);
$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('getResultFactory')->will($this->returnValue($this->resultFactory));
$this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
$this->controller = $this->objectManagerHelper->getObject(\Magento\ConfigurableProduct\Controller\Adminhtml\Product\AddAttribute::class, ['context' => $this->context, 'productBuilder' => $this->productBuilder]);
}
示例14: setUp
protected function setUp()
{
$this->directpostSessionMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Session')->setMethods(['getLastOrderIncrementId', 'removeCheckoutOrderIncrementId', 'isCheckoutOrderIncrementIdExist', 'unsetData'])->disableOriginalConstructor()->getMock();
$this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['getId', 'getState', 'getIncrementId', 'registerCancellation', 'loadByIncrementId', 'save'])->disableOriginalConstructor()->getMock();
$this->adminOrderCreateMock = $this->getMockBuilder('Magento\\Sales\\Model\\AdminOrder\\Create')->setMethods(['getSession'])->disableOriginalConstructor()->getMock();
$sessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->getMock();
$this->sessionQuoteMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session\\Quote')->setMethods(['getOrder', 'clearStorage'])->disableOriginalConstructor()->getMock();
$this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap([['Magento\\Authorizenet\\Model\\Directpost\\Session', $this->directpostSessionMock], ['Magento\\Sales\\Model\\AdminOrder\\Create', $this->adminOrderCreateMock], ['Magento\\Backend\\Model\\Session\\Quote', $this->sessionQuoteMock], ['Magento\\Backend\\Model\\Session', $sessionMock]]);
$this->objectManagerMock->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($this->orderMock);
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['getParams'])->getMockForAbstractClass();
$responseMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface');
$redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
$this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
$this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getObjectManager', 'getRequest', 'getResponse', 'getRedirect', 'getMessageManager'])->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
$this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
$this->contextMock->expects($this->any())->method('getResponse')->willReturn($responseMock);
$this->contextMock->expects($this->any())->method('getRedirect')->willReturn($redirectMock);
$this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
$this->productHelperMock = $this->getMockBuilder('Magento\\Catalog\\Helper\\Product')->disableOriginalConstructor()->getMock();
$this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
$this->resultPageFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->getMock();
$this->forwardFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
$this->coreRegistryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['register'])->disableOriginalConstructor()->getMock();
$resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->disableOriginalConstructor()->getMock();
$this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\LayoutFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
$this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($resultLayoutMock);
$this->helperMock = $this->getMockBuilder('Magento\\Authorizenet\\Helper\\Backend\\Data')->setMethods(['getSuccessOrderUrl'])->disableOriginalConstructor()->getMock();
$this->controller = new Redirect($this->contextMock, $this->productHelperMock, $this->escaperMock, $this->resultPageFactoryMock, $this->forwardFactoryMock, $this->coreRegistryMock, $this->resultLayoutFactoryMock, $this->helperMock);
}
示例15: setUp
public function setUp()
{
$this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
$this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
$this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], [], '', false);
$this->fileSystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->storage = $this->getMock('Magento\\MediaStorage\\Helper\\File\\Storage', [], [], '', false);
$this->objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
$this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
$this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
$this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock);
$this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManager);
$this->urlDecoderMock = $this->getMock('Magento\\Framework\\Url\\DecoderInterface', [], [], '', false);
$this->resultRawMock = $this->getMock('Magento\\Framework\\Controller\\Result\\Raw', [], [], '', false);
$this->resultRawFactoryMock = $this->getMock('Magento\\Framework\\Controller\\Result\\RawFactory', ['create'], [], '', false);
}