本文整理汇总了PHP中Magento\Framework\View\Layout类的典型用法代码示例。如果您正苦于以下问题:PHP Layout类的具体用法?PHP Layout怎么用?PHP Layout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Layout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExecute
/**
* @param bool $cacheState
* @param bool $varnishIsEnabled
* @param bool $scopeIsPrivate
* @param int|null $blockTtl
* @param string $expectedOutput
* @dataProvider processLayoutRenderDataProvider
*/
public function testExecute($cacheState, $varnishIsEnabled, $scopeIsPrivate, $blockTtl, $expectedOutput)
{
$eventMock = $this->getMock('Magento\\Framework\\Event', ['getLayout', 'getElementName', 'getTransport'], [], '', false);
$this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
$eventMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->_layoutMock));
$this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
if ($cacheState) {
$eventMock->expects($this->once())->method('getElementName')->will($this->returnValue('blockName'));
$eventMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transport));
$this->_layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
$this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnSelf());
$this->_layoutMock->expects($this->any())->method('getHandles')->will($this->returnValue([]));
$this->_layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->_blockMock));
if ($varnishIsEnabled) {
$this->_blockMock->expects($this->once())->method('getData')->with('ttl')->will($this->returnValue($blockTtl));
$this->_blockMock->expects($this->any())->method('getUrl')->will($this->returnValue('page_cache/block/wrapesi/with/handles/and/other/stuff'));
}
if ($scopeIsPrivate) {
$this->_blockMock->expects($this->once())->method('getNameInLayout')->will($this->returnValue('testBlockName'));
$this->_blockMock->expects($this->once())->method('isScopePrivate')->will($this->returnValue($scopeIsPrivate));
}
$this->_configMock->expects($this->any())->method('getType')->will($this->returnValue($varnishIsEnabled));
}
$this->_model->execute($this->_observerMock);
$this->assertEquals($expectedOutput, $this->_transport['output']);
}
示例2: initContext
/**
* Init context object
*
* @param array $additionalParams
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function initContext(array $additionalParams = [])
{
$productActionMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Action', [], [], '', false);
$objectManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface');
$objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($productActionMock));
$block = $this->getMockBuilder('\\Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass();
$this->layout = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->setMethods(['getBlock'])->disableOriginalConstructor()->getMock();
$this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($block));
$eventManager = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->setMethods(['dispatch'])->disableOriginalConstructor()->getMock();
$eventManager->expects($this->any())->method('dispatch')->will($this->returnSelf());
$title = $this->getMockBuilder('\\Magento\\Framework\\App\\Action\\Title')->setMethods(['add'])->disableOriginalConstructor()->getMock();
$title->expects($this->any())->method('prepend')->withAnyParameters()->will($this->returnSelf());
$requestInterfaceMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->setMethods(['getParam', 'getPost', 'getFullActionName', 'getPostValue'])->disableOriginalConstructor()->getMock();
$responseInterfaceMock = $this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->setMethods(['setRedirect', 'sendResponse'])->getMock();
$managerInterfaceMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
$sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['getProductData', 'setProductData'], [], '', false);
$actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
$helperDataMock = $this->getMock('Magento\\Backend\\Helper\\Data', [], [], '', false);
$this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getObjectManager', 'getEventManager', 'getMessageManager', 'getSession', 'getActionFlag', 'getHelper', 'getTitle', 'getView', 'getResultRedirectFactory', 'getResultFactory'], [], '', false);
$this->context->expects($this->any())->method('getTitle')->will($this->returnValue($title));
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($requestInterfaceMock));
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($responseInterfaceMock));
$this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($objectManagerMock));
$this->context->expects($this->any())->method('getMessageManager')->will($this->returnValue($managerInterfaceMock));
$this->context->expects($this->any())->method('getSession')->will($this->returnValue($sessionMock));
$this->context->expects($this->any())->method('getActionFlag')->will($this->returnValue($actionFlagMock));
$this->context->expects($this->any())->method('getHelper')->will($this->returnValue($helperDataMock));
foreach ($additionalParams as $property => $object) {
$this->context->expects($this->any())->method('get' . ucfirst($property))->willReturn($object);
}
$this->session = $sessionMock;
$this->request = $requestInterfaceMock;
return $this->context;
}
示例3: _wrapEsi
/**
* Replace the output of the block, containing ttl attribute, with ESI tag
*
* @param \Magento\Framework\View\Element\AbstractBlock $block
* @param \Magento\Framework\View\Layout $layout
* @return string
*/
protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block, \Magento\Framework\View\Layout $layout)
{
$url = $block->getUrl('page_cache/block/esi', ['blocks' => json_encode([$block->getNameInLayout()]), 'handles' => json_encode($layout->getUpdate()->getHandles())]);
// Varnish does not support ESI over HTTPS must change to HTTP
$url = substr($url, 0, 5) === 'https' ? 'http' . substr($url, 5) : $url;
return sprintf('<esi:include src="%s" />', $url);
}
示例4: 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]);
}
示例5: 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);
}
示例6: 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());
}
示例7: 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();
}
示例8: 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());
}
示例9: afterGetOutput
/**
* Set X-Cache-Tags header with all the Magento Cache Tags so
* they can be purged by the CloudFlare API
*
* @param \Magento\Framework\View\Layout $subject
* @param $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if (!$subject->isCacheable() || !$this->config->isEnabled()) {
return $result;
}
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block->getIdentities() !== null) {
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->cacheTagsUtil->setCloudFlareCacheTagsResponseHeader($this->response, $tags);
return $result;
}
示例10: testGenerateElementsWithCache
public function testGenerateElementsWithCache()
{
$layoutCacheId = 'layout_cache_id';
/** @var \Magento\Framework\View\Layout\Element $xml */
$xml = simplexml_load_string('<layout/>', 'Magento\Framework\View\Layout\Element');
$this->model->setXml($xml);
$themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface');
$this->themeResolverMock->expects($this->once())
->method('get')
->willReturn($themeMock);
$this->processorFactoryMock->expects($this->once())
->method('create')
->with(['theme' => $themeMock])
->willReturn($this->processorMock);
$this->processorMock->expects($this->once())
->method('getCacheId')
->willReturn($layoutCacheId);
$readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context')
->disableOriginalConstructor()
->getMock();
$this->cacheMock->expects($this->once())
->method('load')
->with('structure_' . $layoutCacheId)
->willReturn(serialize($readerContextMock));
$this->readerPoolMock->expects($this->never())
->method('interpret');
$this->cacheMock->expects($this->never())
->method('save');
$generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context')
->disableOriginalConstructor()
->getMock();
$this->generatorContextFactoryMock->expects($this->once())
->method('create')
->with(['structure' => $this->structureMock, 'layout' => $this->model])
->willReturn($generatorContextMock);
$this->generatorPoolMock->expects($this->once())
->method('process')
->with($readerContextMock, $generatorContextMock)
->willReturn(true);
$elements = [
'name_1' => ['type' => '', 'parent' => null],
'name_2' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => null],
'name_3' => ['type' => '', 'parent' => 'parent'],
'name_4' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => 'parent'],
];
$this->structureMock->expects($this->once())
->method('exportElements')
->willReturn($elements);
$this->model->generateElements();
}
示例11: _buildEntries
protected function _buildEntries(&$entries, $block, $alias, $level)
{
$blocks = $this->_layout->getAllBlocks();
$extras = array();
$extras[] = count($block->getChild()) ? count($block->getChild()) : "-";
$extras[] = $block->getType();
if ($block->getType() === 'cms/block') {
$extras[] = $block->getBlockId();
} elseif ($block->getType() == 'cms/page') {
$extras[] = $block->getPage()->getIdentifier();
} elseif ($template = $block->getTemplate()) {
$extras[] = $template;
} else {
$extras[] = '-';
}
$extras[] = get_class($block);
// sprintf("$offset%s %s\n", $alias, $this->_colorize($extraString, self::COLOR_DARK_GRAY))
$name = $block->getNameInLayout();
$entry = array('name' => $name, 'alias' => $alias, 'level' => $level, 'extras' => $extras);
$profileName = "BLOCK: {$name}";
if (isset($this->timers[$profileName])) {
$entry['time'] = $this->timers[$profileName]['sum'] * 1000;
}
$entries[] = $entry;
foreach ($block->getChild() as $alias => $childBlock) {
$this->_buildEntries($entries, $childBlock, $alias, $level + 1);
}
}
示例12: buildEntries
protected function buildEntries(MagentoLayout $layout, &$structure, $name = 'root', $alias = '', $level = 0)
{
if (!isset($structure[$name])) {
return [];
}
$instance = $layout->getBlock($name);
$block = $structure[$name];
$entries = [];
$entries[] = ['level' => $level, 'name' => $name, 'alias' => $alias, 'type' => $block['type'], 'label' => isset($block['label']) ? $block['label'] : '', 'extra' => array_filter(['htmlTag' => isset($block['htmlTag']) ? $block['htmlTag'] : '', 'htmlId' => isset($block['htmlId']) ? $block['htmlId'] : '', 'htmlClass' => isset($block['htmlClass']) ? $block['htmlClass'] : '', 'template' => $instance ? $instance->getTemplate() : ''])];
if (isset($block['children'])) {
foreach ($block['children'] as $child => $alias) {
$entries = array_merge($entries, $this->buildEntries($layout, $structure, $child, $alias, $level + 1));
}
}
return $entries;
}
示例13: testExecute
public function testExecute()
{
$blocks = ['block1', 'block2'];
$handles = ['handle1', 'handle2'];
$originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}';
$expectedData = ['block1' => 'data1', 'block2' => 'data2'];
$blockInstance1 = $this->getMock('Magento\\PageCache\\Test\\Unit\\Block\\Controller\\StubBlock', ['toHtml'], [], '', false);
$blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1']));
$blockInstance2 = $this->getMock('Magento\\PageCache\\Test\\Unit\\Block\\Controller\\StubBlock', ['toHtml'], [], '', false);
$blockInstance2->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block2']));
$this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
$this->requestMock->expects($this->at(1))->method('getRouteName')->will($this->returnValue('magento_pagecache'));
$this->requestMock->expects($this->at(2))->method('getControllerName')->will($this->returnValue('block'));
$this->requestMock->expects($this->at(3))->method('getActionName')->will($this->returnValue('render'));
$this->requestMock->expects($this->at(4))->method('getRequestUri')->will($this->returnValue('uri'));
$this->requestMock->expects($this->at(5))->method('getParam')->with($this->equalTo('originalRequest'))->will($this->returnValue($originalRequest));
$this->requestMock->expects($this->at(10))->method('getParam')->with($this->equalTo('blocks'), $this->equalTo(''))->will($this->returnValue(json_encode($blocks)));
$this->requestMock->expects($this->at(11))->method('getParam')->with($this->equalTo('handles'), $this->equalTo(''))->will($this->returnValue(json_encode($handles)));
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
$this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
$this->layoutMock->expects($this->at(0))->method('getBlock')->with($this->equalTo($blocks[0]))->will($this->returnValue($blockInstance1));
$this->layoutMock->expects($this->at(1))->method('getBlock')->with($this->equalTo($blocks[1]))->will($this->returnValue($blockInstance2));
$this->translateInline->expects($this->once())->method('processResponseBody')->with($expectedData)->willReturnSelf();
$this->responseMock->expects($this->once())->method('appendBody')->with($this->equalTo(json_encode($expectedData)));
$this->action->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: testGetItemPrice
public function testGetItemPrice()
{
$html = '$34.28';
$this->layoutMock->expects($this->once())->method('getBlock')->with('item_price')->will($this->returnValue($this->priceRenderBlock));
$this->priceRenderBlock->expects($this->once())->method('setItem')->with($this->itemMock);
$this->priceRenderBlock->expects($this->once())->method('toHtml')->will($this->returnValue($html));
$this->assertEquals($html, $this->block->getItemPrice($this->itemMock));
}