• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP View\Layout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\View\Layout的典型用法代码示例。如果您正苦于以下问题:PHP Layout类的具体用法?PHP Layout怎么用?PHP Layout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Layout类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:ProcessLayoutRenderElementTest.php


示例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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:41,代码来源:ProductTest.php


示例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);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:ProcessLayoutRenderElement.php


示例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]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:34,代码来源:EditTest.php


示例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);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:16,代码来源:IndexTest.php


示例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());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:DeleteTest.php


示例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();
 }
开发者ID:nblair,项目名称:magescotch,代码行数:15,代码来源:IndexTest.php


示例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());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:IndexTest.php


示例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;
 }
开发者ID:cloudflare,项目名称:cloudflare-magento,代码行数:23,代码来源:LayoutPlugin.php


示例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();
    }
开发者ID:nja78,项目名称:magento2,代码行数:60,代码来源:LayoutTest.php


示例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);
     }
 }
开发者ID:llapgoch,项目名称:magento2-developer-toolbar,代码行数:28,代码来源:BlockPanel.php


示例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;
 }
开发者ID:balloz,项目名称:magento2-developer-toolbar,代码行数:16,代码来源:Layout.php


示例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();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:RenderTest.php


示例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]);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:27,代码来源:ViewTest.php


示例15: testAddDefaultHandle

 public function testAddDefaultHandle()
 {
     $processor = $this->getMock('Magento\\Framework\\View\\Layout\\ProcessorInterface', [], [], '', false);
     $processor->expects($this->once())->method('addHandle')->with('module_controller_action');
     $this->layout->expects($this->once())->method('getUpdate')->will($this->returnValue($processor));
     $this->request->expects($this->once())->method('getFullActionName')->will($this->returnValue('Module_Controller_Action'));
     $this->assertSame($this->resultLayout, $this->resultLayout->addDefaultHandle());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:LayoutTest.php


示例16: setUp

 protected function setUp()
 {
     $this->layout = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->setMethods(['addHandle', 'getUpdate', 'isLayoutDefined'])->disableOriginalConstructor()->getMock();
     $this->layoutFactory = $this->getMockBuilder('Magento\\Framework\\View\\LayoutFactory')->disableOriginalConstructor()->getMock();
     $this->layoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->layout));
     $this->layoutMerge = $this->getMockBuilder('Magento\\Framework\\View\\Model\\Layout\\Merge')->disableOriginalConstructor()->getMock();
     $this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->layoutMerge));
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->viewFileSystem = $this->getMockBuilder('Magento\\Framework\\View\\FileSystem')->disableOriginalConstructor()->getMock();
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->context = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\Template\\Context', ['layout' => $this->layout, 'request' => $this->request, 'viewFileSystem' => $this->viewFileSystem, 'pageConfig' => $this->pageConfig]);
     $this->translateInline = $this->getMock('Magento\\Framework\\Translate\\InlineInterface');
     $this->pageConfigRenderer = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\Renderer')->disableOriginalConstructor()->getMock();
     $pageConfigRendererFactory = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\RendererFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $pageConfigRendererFactory->expects($this->once())->method('create')->with(['pageConfig' => $this->pageConfig])->willReturn($this->pageConfigRenderer);
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->page = $objectManagerHelper->getObject('Magento\\Framework\\View\\Result\\Page', ['isIsolated' => true, 'layoutFactory' => $this->layoutFactory, 'context' => $this->context, 'translateInline' => $this->translateInline, 'pageConfigRendererFactory' => $pageConfigRendererFactory]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:PageTest.php


示例17: afterGetOutput

 /**
  * Retrieve all identities from blocks for further cache invalidation
  *
  * @param \Magento\Framework\View\Layout $subject
  * @param mixed $result
  * @return mixed
  */
 public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
 {
     if ($subject->isCacheable() && $this->config->isEnabled()) {
         $tags = [];
         foreach ($subject->getAllBlocks() as $block) {
             if ($block instanceof \Magento\Framework\DataObject\IdentityInterface) {
                 $isEsiBlock = $block->getTtl() > 0;
                 $isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH;
                 if ($isVarnish && $isEsiBlock) {
                     continue;
                 }
                 $tags = array_merge($tags, $block->getIdentities());
             }
         }
         $tags = array_unique($tags);
         $this->response->setHeader('X-Magento-Tags', implode(',', $tags));
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:LayoutPlugin.php


示例18: 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));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:DefaultItemsTest.php


示例19: testAroundRenderTrue

 public function testAroundRenderTrue()
 {
     $attributeMock = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $this->filterMock->expects($this->atLeastOnce())->method('getAttributeModel')->willReturn($attributeMock);
     $this->filterMock->expects($this->once())->method('hasAttributeModel')->willReturn(true);
     $this->swatchHelperMock->expects($this->once())->method('isSwatchAttribute')->with($attributeMock)->willReturn(true);
     $this->layoutMock->expects($this->once())->method('createBlock')->willReturn($this->blockMock);
     $this->blockMock->expects($this->once())->method('setSwatchFilter')->will($this->returnSelf());
     $this->plugin->aroundRender($this->filterRendererMock, $this->closureMock, $this->filterMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:FilterRendererTest.php


示例20: execute

 /**
  * Categories chooser Action (Ajax request)
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $selected = $this->getRequest()->getParam('selected', '');
     $isAnchorOnly = $this->getRequest()->getParam('is_anchor_only', 0);
     /** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */
     $chooser = $this->layout->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser')->setUseMassaction(true)->setId($this->mathRandom->getUniqueHash('categories'))->setIsAnchorOnly($isAnchorOnly)->setSelectedCategories(explode(',', $selected));
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     return $resultRaw->setContents($chooser->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Categories.php



注:本文中的Magento\Framework\View\Layout类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP View\LayoutFactory类代码示例发布时间:2022-05-23
下一篇:
PHP View\FileSystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap