本文整理汇总了PHP中Magento\Framework\Controller\ResultFactory::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultFactory::expects方法的具体用法?PHP ResultFactory::expects怎么用?PHP ResultFactory::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Controller\ResultFactory
的用法示例。
在下文中一共展示了ResultFactory::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
$this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false);
$this->itemCarrier = $this->getMock('Magento\Wishlist\Model\ItemCarrier', [], [], '', false);
$this->formKeyValidator = $this->getMock('Magento\Framework\Data\Form\FormKey\Validator', [], [], '', false);
$this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
->disableOriginalConstructor()
->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect')
->disableOriginalConstructor()
->getMock();
$this->resultForwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward')
->disableOriginalConstructor()
->getMock();
$this->resultFactoryMock->expects($this->any())
->method('create')
->willReturnMap(
[
[ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock],
[ResultFactory::TYPE_FORWARD, [], $this->resultForwardMock]
]
);
}
示例2: setUp
protected function setUp()
{
$this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
$this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
$this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false);
$this->redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
->disableOriginalConstructor()
->getMock();
$this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page')
->disableOriginalConstructor()
->getMock();
$this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
->disableOriginalConstructor()
->getMock();
$this->resultFactoryMock->expects($this->any())
->method('create')
->with(ResultFactory::TYPE_PAGE, [])
->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->any())
->method('getLayout')
->willReturn($this->layoutMock);
}
示例3: 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]);
}
示例4: testExecute
public function testExecute()
{
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
$resultLayout = $this->getMock(\Magento\Framework\View\Result\Layout::class, [], [], '', false);
$this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_LAYOUT)->willReturn($resultLayout);
$this->assertInstanceOf(\Magento\Framework\View\Result\Layout::class, $this->controller->execute());
}
示例5: setUp
public function setUp()
{
$this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
$this->wishlistProvider = $this->getMock('Magento\\Wishlist\\Controller\\WishlistProvider', ['getWishlist'], [], '', false);
$this->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', ['getBeforeWishlistRequest', 'unsBeforeWishlistRequest', 'getBeforeWishlistUrl', 'setAddActionReferer', 'setBeforeWishlistUrl'], [], '', false);
$this->productRepository = $this->getMock('\\Magento\\Catalog\\Model\\ProductRepository', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
}
示例6: testExecute
public function testExecute()
{
$_FILES['test_key'] = [];
$result = ['file' => '', 'url' => ''];
$resultJson = '{"file": "", "url": ""}';
$this->imageProcessor->expects($this->once())->method('saveToTmp')->with('test_key')->willReturn($result);
$this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_JSON)->willReturn($this->resultPage);
$this->resultPage->expects($this->once())->method('setData')->with($result)->willReturn($resultJson);
$this->assertEquals($resultJson, $this->controller->execute());
}
示例7: 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
]
);
}
示例8: setUp
protected function setUp()
{
$this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
$this->factory = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
$this->registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_LAYOUT, [])->willReturn($this->resultLayoutMock);
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->context = $this->objectManager->getObject('Magento\\Backend\\App\\Action\\Context', ['request' => $this->request, 'resultFactory' => $this->resultFactoryMock]);
$this->action = $this->objectManager->getObject('Magento\\GroupedProduct\\Controller\\Adminhtml\\Edit\\Popup', ['context' => $this->context, 'factory' => $this->factory, 'registry' => $this->registry]);
}
示例9: 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);
}
示例10: setUp
protected function setUp()
{
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getPostValue'])->getMockForAbstractClass();
$this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->getMock();
$this->messageManagerMock = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->getMock();
$this->resultFactoryMock->expects($this->once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($this->resultRedirectMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->context = $this->objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', ['resultFactory' => $this->resultFactoryMock, 'request' => $this->requestMock, 'messageManager' => $this->messageManagerMock, 'objectManager' => $this->objectManagerMock]);
$this->saveController = $this->objectManagerHelper->getObject('Magento\\Sitemap\\Controller\\Adminhtml\\Sitemap\\Save', ['context' => $this->context]);
}
示例11: 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,
]
);
}
示例12: 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]);
}
示例13: setUp
protected function setUp()
{
$this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
$this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$this->wishlistProvider = $this->getMock('Magento\\Wishlist\\Controller\\WishlistProvider', [], [], '', false);
$this->redirect = $this->getMock('\\Magento\\Store\\App\\Response\\Redirect', [], [], '', false);
$this->om = $this->getMock('Magento\\Framework\\App\\ObjectManager', [], [], '', false);
$this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
$this->url = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
}
示例14: setUp
protected function setUp()
{
$this->wishlistProviderMock = $this->getMockBuilder('Magento\\Wishlist\\Controller\\Shared\\WishlistProvider')->disableOriginalConstructor()->getMock();
$this->itemCarrierMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\ItemCarrier')->disableOriginalConstructor()->getMock();
$this->wishlistMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$this->resultForwardMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Forward')->disableOriginalConstructor()->getMock();
$this->resultFactoryMock->expects($this->any())->method('create')->willReturnMap([[ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock], [ResultFactory::TYPE_FORWARD, [], $this->resultForwardMock]]);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->context = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Action\\Context', ['request' => $this->requestMock, 'resultFactory' => $this->resultFactoryMock]);
$this->allcartController = $this->objectManagerHelper->getObject('Magento\\Wishlist\\Controller\\Shared\\Allcart', ['context' => $this->context, 'wishlistProvider' => $this->wishlistProviderMock, 'itemCarrier' => $this->itemCarrierMock]);
}
示例15: _prepareMockObjects
/**
* Get mock objects for SetUp()
*/
protected function _prepareMockObjects()
{
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$this->storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface');
$this->storeModelMock = $this->getMock('Magento\\Store\\Model\\Store', ['__wakeup', 'getId'], [], '', false);
$this->reviewMock = $this->getMock('Magento\\Review\\Model\\Review', ['__wakeup', 'create', 'save', 'getId', 'getResource', 'aggregate'], [], '', false);
$this->reviewFactoryMock = $this->getMock('Magento\\Review\\Model\\ReviewFactory', ['create'], [], '', false);
$this->ratingMock = $this->getMock('Magento\\Review\\Model\\Rating', ['__wakeup', 'setRatingId', 'setReviewId', 'addOptionVote'], [], '', false);
$this->ratingFactoryMock = $this->getMock('Magento\\Review\\Model\\RatingFactory', ['create'], [], '', 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);
}