本文整理汇总了PHP中Magento\Framework\View\Result\Page::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::expects方法的具体用法?PHP Page::expects怎么用?PHP Page::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Result\Page
的用法示例。
在下文中一共展示了Page::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
$this->registryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->setMethods(['registry', 'register'])->getMock();
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->viewMock = $this->getMockBuilder('Magento\\Framework\\App\\View')->disableOriginalConstructor()->setMethods(['loadLayout', 'getLayout', 'getPage', 'renderLayout'])->getMock();
$this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods(['getBlock', 'createBlock', 'setChild'])->getMock();
$this->menuBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->setMethods(['setActive', 'getMenuModel', 'getParentItems'])->getMock();
$this->breadcrumbsBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Widget\\Breadcrumbs')->disableOriginalConstructor()->setMethods(['addLink'])->getMock();
$this->editBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Widget\\Breadcrumbs')->disableOriginalConstructor()->setMethods(['setEditMode'])->getMock();
$this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb'])->getMock();
$this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
$this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
$this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
$this->layoutMock->expects($this->any())->method('getBlock')->willReturnMap([['menu', $this->menuBlockMock], ['breadcrumbs', $this->breadcrumbsBlockMock], ['edit', $this->editBlockMock]]);
$this->menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
$this->menuBlockMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
$this->viewMock->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);
$this->layoutMock->expects($this->once())->method('createBlock')->with('Magento\\Email\\Block\\Adminhtml\\Template\\Edit', 'template_edit', [])->willReturn($this->editBlockMock);
$this->editBlockMock->expects($this->once())->method('setEditMode')->willReturnSelf();
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$templateMock = $this->getMockBuilder('Magento\\Email\\Model\\Template')->disableOriginalConstructor()->getMock();
$templateMock->expects($this->once())->method('getId')->willReturn(1);
$templateMock->expects($this->any())->method('getTemplateCode')->willReturn('My Template');
$objectManagerMock = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->getMock();
$objectManagerMock->expects($this->once())->method('create')->with('Magento\\Email\\Model\\BackendTemplate')->willReturn($templateMock);
$this->context = $objectManager->getObject('Magento\\Backend\\App\\Action\\Context', ['request' => $this->requestMock, 'objectManager' => $objectManagerMock, 'view' => $this->viewMock]);
$this->editController = $objectManager->getObject('Magento\\Email\\Controller\\Adminhtml\\Email\\Template\\Edit', ['context' => $this->context, 'coreRegistry' => $this->registryMock]);
}
示例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: testExecuteResultPage
public function testExecuteResultPage()
{
$this->resultPageMock->expects($this->at(0))->method('setStatusHeader')->with(404, '1.1', 'Not Found')->will($this->returnSelf());
$this->resultPageMock->expects($this->at(1))->method('setHeader')->with('Status', '404 File not found')->will($this->returnSelf());
$this->_cmsHelperMock->expects($this->once())->method('prepareResultPage')->will($this->returnValue($this->resultPageMock));
$this->assertSame($this->resultPageMock, $this->_controller->execute());
}
示例4: testExecuteInternal
public function testExecuteInternal()
{
$this->viewMock->expects($this->once())->method('getPage')->willReturn($this->pageMock);
$this->pageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
$this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
$this->pageTitleMock->expects($this->once())->method('prepend')->willReturnSelf();
$this->assertNull($this->object->executeInternal());
}
示例5: testCreateActionRegistrationDisabled
/**
* @return void
*/
public function testCreateActionRegistrationDisabled()
{
$this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
$this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false));
$this->redirectFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectResultMock);
$this->redirectResultMock->expects($this->once())->method('setPath')->with('*/*')->willReturnSelf();
$this->resultPageMock->expects($this->never())->method('getLayout');
$this->object->execute();
}
示例6: 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();
}
示例7: testCreateActionRegistrationEnabled
/**
* @return void
*/
public function testCreateActionRegistrationEnabled()
{
$this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
$this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
$this->redirectMock->expects($this->never())->method('redirect');
$layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
$layoutMock->expects($this->once())->method('initMessages')->willReturnSelf();
$this->pageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
$this->object->execute();
}
示例8: testExecute
/**
* @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
*/
public function testExecute()
{
$this->prepareExecute();
$this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Customer::customer_manage');
$this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
$this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
$this->pageTitleMock->expects($this->once())->method('prepend')->with('Customers');
$this->resultPageMock->expects($this->atLeastOnce())->method('addBreadcrumb')->withConsecutive(['Customers', 'Customers'], ['Manage Customers', 'Manage Customers']);
$this->sessionMock->expects($this->once())->method('unsCustomerData');
$this->assertInstanceOf('Magento\\Framework\\View\\Result\\Page', $this->indexController->execute());
}
示例9: testExecutePageReload
public function testExecutePageReload()
{
$this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(null);
$this->request->expects($this->any())->method('getParams')->willReturn([]);
$this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
$this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
$title = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['prepend'])->disableOriginalConstructor()->getMock();
$config = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->setMethods(['getTitle'])->disableOriginalConstructor()->getMock();
$config->expects($this->any())->method('getTitle')->willReturn($title);
$this->resultPage->expects($this->any())->method('getConfig')->willReturn($config);
$this->assertSame($this->resultPage, $this->object->execute());
}
示例10: setUp
/**
* test setup
*/
public function setUp()
{
$this->pageConfig = $this->getMockBuilder('\\Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->setMethods(['set', 'getTitle'])->getMock();
$this->resultPageFactory = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
$this->resultPage = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
$this->block = $this->getMockBuilder('\\Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock();
$this->pageLayout = $this->getMockBuilder('\\Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
$this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->resultPage);
$this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->pageLayout);
$this->pageLayout->expects($this->any())->method('getBlock')->willReturn($this->block);
$this->pageConfig->expects($this->once())->method('getTitle')->willReturnSelf();
$this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
}
示例11: testExecute
/**
* Executes the controller action and asserts non exception logic
*/
public function testExecute()
{
$objectManager = new ObjectManagerHelper($this);
$this->vault->expects($this->once())->method('storedCard')->willReturn(true);
$this->request->expects($this->any())->method('getParam')->willReturn('token');
$this->resultRedirectFactory->expects($this->never())->method('create')->willReturn($this->resultRedirect);
$this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->resultPage);
$this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->pageLayout);
$this->pageLayout->expects($this->any())->method('getBlock')->willReturn($this->block);
$this->pageConfig->expects($this->once())->method('getTitle')->willReturnSelf();
$this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
$notification = $objectManager->getObject('Magento\\Braintree\\Controller\\Creditcard\\Delete', ['request' => $this->request, 'resultPageFactory' => $this->resultPageFactory, 'vault' => $this->vault]);
$this->assertSame($this->resultPage, $notification->execute());
}
示例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
/**
* @covers \Magento\Email\Controller\Adminhtml\Email\Template\Index::execute
*/
public function testExecute()
{
$this->prepareExecute();
$this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
$this->layoutMock->expects($this->at(0))->method('getBlock')->with('menu')->will($this->returnValue($this->menuBlockMock));
$this->menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
$this->menuBlockMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
$this->viewMock->expects($this->once())->method('getPage')->willReturn($this->resultPageMock);
$this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
$this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
$this->pageTitleMock->expects($this->once())->method('prepend')->with('Email Templates');
$this->layoutMock->expects($this->at(1))->method('getBlock')->with('breadcrumbs')->will($this->returnValue($this->breadcrumbsBlockMock));
$this->breadcrumbsBlockMock->expects($this->any())->method('addLink')->willReturnSelf();
$this->assertNull($this->indexController->execute());
}
示例14: testExecute
/**
* Test execute
*
* @return void
*/
public function testExecute()
{
$data = ['comment' => 'test comment'];
$invoiceId = 2;
$response = 'some result';
$this->requestMock->expects($this->at(0))->method('getParam')->with('id')->willReturn($invoiceId);
$this->requestMock->expects($this->at(1))->method('setParam');
$this->requestMock->expects($this->at(2))->method('getPost')->with('comment')->willReturn($data);
$this->requestMock->expects($this->at(3))->method('getParam')->with('invoice_id')->willReturn($invoiceId);
$invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
$invoiceMock->expects($this->once())->method('addComment')->with($data['comment'], false, false);
$invoiceMock->expects($this->once())->method('save');
$invoiceMock->expects($this->once())->method('load')->willReturnSelf();
$this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
$commentsBlockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Invoice\\View\\Comments')->disableOriginalConstructor()->setMethods([])->getMock();
$commentsBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
$layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock();
$layoutMock->expects($this->once())->method('getBlock')->with('invoice_comments')->will($this->returnValue($commentsBlockMock));
$this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock));
$this->resultPageMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
$this->commentSenderMock->expects($this->once())->method('send')->with($invoiceMock, false, $data['comment']);
$resultRaw = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Raw')->disableOriginalConstructor()->setMethods([])->getMock();
$resultRaw->expects($this->once())->method('setContents')->with($response);
$this->resultRawFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRaw));
$this->assertSame($resultRaw, $this->controller->execute());
}
示例15: 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());
}