本文整理汇总了PHP中Magento\Framework\App\ViewInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewInterface::expects方法的具体用法?PHP ViewInterface::expects怎么用?PHP ViewInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\ViewInterface
的用法示例。
在下文中一共展示了ViewInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExecute
/**
* @return void
*/
public function testExecute()
{
$titleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
$titleMock->expects($this->once())->method('prepend')->with(new Phrase('Account Activity'));
$this->viewMock->expects($this->any())->method('getPage')->willReturn(new DataObject(['config' => new DataObject(['title' => $titleMock])]));
$this->controller->execute();
}
示例2: testExecuteInternal
public function testExecuteInternal()
{
$this->view->expects($this->once())
->method('loadLayout')
->with(false);
$this->view->expects($this->once())
->method('renderLayout');
$this->controller->executeInternal();
}
示例3: testExecute
public function testExecute()
{
$this->view->expects($this->any())->method('loadLayout')->will($this->returnValue(1));
$this->view->expects($this->any())->method('getPage')->will($this->returnValue($this->page));
$this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->config));
$this->config->expects($this->any())->method('getTitle')->will($this->returnValue($this->title));
$this->title->expects($this->any())->method('prepend')->with(__('Index Management'))->will($this->returnValue(1));
$this->view->expects($this->any())->method('renderLayout')->will($this->returnValue(1));
$this->object->execute();
}
示例4: testExecute
public function testExecute()
{
$layout = $this->getMock('\\Magento\\Framework\\View\\Layout', ['getBlock', 'initMessages'], [], '', false);
$block = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Element\\AbstractBlock', ['setFormAction'], '', false);
$layout->expects($this->once())->method('getBlock')->with('contactForm')->will($this->returnValue($block));
$this->_view->expects($this->once())->method('loadLayout');
$this->_view->expects($this->exactly(1))->method('getLayout')->will($this->returnValue($layout));
$this->_view->expects($this->once())->method('renderLayout');
$this->_controller->execute();
}
示例5: testExecute
/**
* @covers \Magento\Authorizenet\Controller\Directpost\Payment\Redirect::execute
*/
public function testExecute()
{
$url = 'http://test.com/redirect?=test';
$params = ['order_success' => $url];
$this->request->expects(static::once())->method('getParams')->willReturn($params);
$this->coreRegistry->expects(static::once())->method('register')->with(Iframe::REGISTRY_KEY, []);
$this->view->expects(static::once())->method('addPageLayoutHandles');
$this->view->expects(static::once())->method('loadLayout')->with(false)->willReturnSelf();
$this->view->expects(static::once())->method('renderLayout');
$this->controller->execute();
}
示例6: testGetCustomerDepersonalizeCustomerData
/**
* test getCustomer method, method returns depersonalized customer Data
*/
public function testGetCustomerDepersonalizeCustomerData()
{
$this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
$this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
$this->viewMock->expects($this->once())->method('isLayoutLoaded')->will($this->returnValue(true));
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(true));
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue($this->customerGroupId));
$this->customerInterfaceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->customerDataMock));
$this->customerDataMock->expects($this->once())->method('setGroupId')->with($this->equalTo($this->customerGroupId))->will($this->returnSelf());
$this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
}
示例7: testExecute
public function testExecute()
{
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle\\Option\\Search\\Grid')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
$this->request->expects($this->once())->method('getParam')->with('index')->willReturn('index');
$this->view->expects($this->once())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$block->expects($this->once())->method('setIndex')->willReturnSelf();
$block->expects($this->once())->method('toHtml')->willReturnSelf();
$this->assertEquals($this->response, $this->controller->execute());
}
示例8: testExecute
public function testExecute()
{
$product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
$this->initializationHelper->expects($this->any())->method('initialize')->willReturn($product);
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
$this->view->expects($this->once())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$block->expects($this->once())->method('toHtml')->willReturnSelf();
$this->controller->execute();
}
示例9: testExecute
public function testExecute()
{
$product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\ConfigurableProduct\\Block\\Adminhtml\\Product\\Attribute\\NewAttribute\\Product\\Created')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->view->expects($this->once())->method('loadLayout')->with('popup')->willReturnSelf();
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
$this->view->expects($this->any())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$layout->expects($this->once())->method('setChild')->willReturnSelf();
$this->view->expects($this->any())->method('renderLayout')->willReturnSelf();
$this->controller->execute();
}
示例10: testExecute
public function testExecute()
{
$layout = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false);
$storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false);
$block = $this->getMockForAbstractClass(
'Magento\Framework\View\Element\BlockInterface',
[],
'',
false,
false,
true,
['setStorage']
);
$this->view->expects($this->once())
->method('loadLayout')
->with('empty');
$this->view->expects($this->once())
->method('getLayout')
->willReturn($layout);
$layout->expects($this->once())
->method('getBlock')
->with('wysiwyg_files.files')
->willReturn($block);
$block->expects($this->once())
->method('setStorage')
->with($storage);
$this->objectManager->expects($this->at(0))
->method('get')
->with('Magento\Theme\Model\Wysiwyg\Storage')
->willReturn($storage);
$this->storage->expects($this->once())
->method('getCurrentPath')
->willThrowException(new \Exception('Message'));
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$jsonData->expects($this->once())
->method('jsonEncode')
->with(['error' => true, 'message' => 'Message'])
->willReturn('{"error":"true","message":"Message"}');
$this->objectManager->expects($this->at(1))
->method('get')
->with('Magento\Framework\Json\Helper\Data')
->willReturn($jsonData);
$this->response->expects($this->once())
->method('representJson');
$this->controller->executeInternal();
}
示例11: setUp
protected function setUp()
{
$this->_eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
$this->_actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
$this->_redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface', [], [], '', false);
$this->_requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->_responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
$this->pageConfigMock = $this->getMock('Magento\\Framework\\View\\Page\\Config', ['getConfig'], [], '', false);
$this->viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
$this->viewMock->expects($this->any())->method('getPage')->will($this->returnValue($this->pageConfigMock));
$this->pageConfigMock->expects($this->any())->method('getConfig')->will($this->returnValue(1));
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->action = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\ActionFake', ['request' => $this->_requestMock, 'response' => $this->_responseMock, 'eventManager' => $this->_eventManagerMock, 'redirect' => $this->_redirectMock, 'actionFlag' => $this->_actionFlagMock, 'view' => $this->viewMock]);
\Magento\Framework\Profiler::disable();
}
示例12: testExecute
public function testExecute()
{
$this->menuMock->expects($this->once())->method('getParentItems')->willReturn([$this->menuItemMock]);
$this->titleMock->expects($this->atLeastOnce())->method('prepend');
$this->pageConfigMock->expects($this->atLeastOnce())->method('getTitle')->willReturn($this->titleMock);
$this->pageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock);
$this->blockMock->expects($this->atLeastOnce())->method('addLink');
$this->blockMock->expects($this->once())->method('setActive');
$this->blockMock->expects($this->once())->method('getMenuModel')->willReturn($this->menuMock);
$this->layoutMock->expects($this->atLeastOnce())->method('getBlock')->willReturn($this->blockMock);
$this->viewMock->expects($this->once())->method('loadLayout')->willReturnSelf();
$this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
$this->viewMock->expects($this->atLeastOnce())->method('getPage')->willReturn($this->pageMock);
$this->action->executeInternal();
}
示例13: testExecute
public function testExecute()
{
$shipmentId = 1000012;
$orderId = 10003;
$tracking = [];
$shipmentData = ['items' => [], 'send_email' => ''];
$shipment = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['load', 'save', 'register', 'getOrder', 'getOrderId', '__wakeup'], [], '', false);
$this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipmentData], ['tracking', null, $tracking]]));
$this->shipmentLoader->expects($this->any())->method('setShipmentId')->with($shipmentId);
$this->shipmentLoader->expects($this->any())->method('setOrderId')->with($orderId);
$this->shipmentLoader->expects($this->any())->method('setShipment')->with($shipmentData);
$this->shipmentLoader->expects($this->any())->method('setTracking')->with($tracking);
$this->shipmentLoader->expects($this->once())->method('load')->will($this->returnValue($shipment));
$this->session->expects($this->once())->method('getCommentText')->with(true)->will($this->returnValue(''));
$this->objectManager->expects($this->atLeastOnce())->method('get')->with('Magento\\Backend\\Model\\Session')->will($this->returnValue($this->session));
$this->view->expects($this->once())->method('loadLayout')->will($this->returnSelf());
$this->view->expects($this->once())->method('renderLayout')->will($this->returnSelf());
$this->view->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
$this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
$layout = $this->getMock('Magento\\Framework\\View\\Layout\\Element\\Layout', ['getBlock'], [], '', false);
$menuBlock = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface', ['toHtml', 'setActive', 'getMenuModel'], [], '', false);
$menuModel = $this->getMockBuilder('Magento\\Backend\\Model\\Menu')->disableOriginalConstructor()->getMock();
$itemId = 'Magento_Sales::sales_order';
$parents = [new \Magento\Framework\DataObject(['title' => 'title1']), new \Magento\Framework\DataObject(['title' => 'title2']), new \Magento\Framework\DataObject(['title' => 'title3'])];
$menuModel->expects($this->once())->method('getParentItems')->with($itemId)->will($this->returnValue($parents));
$menuBlock->expects($this->once())->method('setActive')->with($itemId);
$menuBlock->expects($this->once())->method('getMenuModel')->will($this->returnValue($menuModel));
$this->view->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
$layout->expects($this->once())->method('getBlock')->with('menu')->will($this->returnValue($menuBlock));
$this->assertNull($this->newAction->execute());
}
示例14: setUp
public function setUp()
{
$this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
$this->categoryHelper = $this->getMock('Magento\\Catalog\\Helper\\Category', [], [], '', false);
$this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false);
$this->eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
$this->update = $this->getMock('Magento\\Framework\\View\\Layout\\ProcessorInterface');
$this->layout = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
$this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update));
$this->view = $this->getMock('Magento\\Framework\\App\\ViewInterface');
$this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
$this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
$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('getObjectManager')->will($this->returnValue($this->objectManager));
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($this->eventManager));
$this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
$this->category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
$this->categoryFactory = $this->getMock('Magento\\Catalog\\Model\\CategoryFactory', ['create'], [], '', false);
$this->store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
$this->catalogDesign = $this->getMock('Magento\\Catalog\\Model\\Design', [], [], '', false);
$this->layoutHelper = $this->getMock('Magento\\Theme\\Helper\\Layout', [], [], '', false);
$this->action = (new ObjectManager($this))->getObject('Magento\\Catalog\\Controller\\Category\\View', ['context' => $this->context, 'catalogDesign' => $this->catalogDesign, 'categoryFactory' => $this->categoryFactory, 'storeManager' => $this->storeManager]);
}
示例15: setUp
protected function setUp()
{
$this->shipmentLoaderMock = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load', '__wakeup'], [], '', false);
$this->shipmentCommentSenderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender\\ShipmentCommentSender', ['send', '__wakeup'], [], '', false);
$this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam', 'getPost', 'setParam', '__wakeup'], [], '', false);
$this->responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', ['setBody', 'representJson', '__wakeup'], [], '', false);
$this->resultLayoutFactoryMock = $this->getMock('Magento\\Framework\\View\\Result\\LayoutFactory', ['create'], [], '', false);
$this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
$this->shipmentMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['save', 'addComment', '__wakeup'], [], '', false);
$this->viewInterfaceMock = $this->getMock('Magento\\Framework\\App\\ViewInterface', [], [], '', false);
$this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getTitle', 'getView', 'getObjectManager', '__wakeup'], [], '', false);
$this->viewInterfaceMock->expects($this->any())->method('getPage')->will($this->returnValue($this->resultPageMock));
$contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
$contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
$contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewInterfaceMock));
$contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
$this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddComment($contextMock, $this->shipmentLoaderMock, $this->shipmentCommentSenderMock, $this->resultLayoutFactoryMock);
}