當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractBlock::expects方法代碼示例

本文整理匯總了PHP中Magento\Framework\View\Element\AbstractBlock::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractBlock::expects方法的具體用法?PHP AbstractBlock::expects怎麽用?PHP AbstractBlock::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\View\Element\AbstractBlock的用法示例。


在下文中一共展示了AbstractBlock::expects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: testGetRenderer

 public function testGetRenderer()
 {
     $this->blockMock->expects($this->any())->method('setRenderedBlock')->will($this->returnValue($this->blockMock));
     $this->blockMock->expects($this->any())->method('getTemplate')->will($this->returnValue('template'));
     $this->blockMock->expects($this->any())->method('setTemplate')->will($this->returnValue($this->blockMock));
     $this->layoutMock->expects($this->any())->method('getChildName')->will($this->returnValue(true));
     /** During the first call cache will be generated */
     $this->assertInstanceOf('\\Magento\\Framework\\View\\Element\\BlockInterface', $this->renderList->getRenderer('type', null, null));
     /** Cached value should be returned during second call */
     $this->assertInstanceOf('\\Magento\\Framework\\View\\Element\\BlockInterface', $this->renderList->getRenderer('type', null, 'renderer_template'));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:RendererListTest.php

示例3: setUp

 /**
  * Set up test
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getAuthorization', 'getSession', 'getActionFlag', 'getAuth', 'getView', 'getHelper', 'getBackendUrl', 'getFormKeyValidator', 'getLocaleResolver', 'getCanUseBaseUrl', 'getRequest', 'getResponse', 'getObjectManager', 'getMessageManager'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\RequestInterface', ['getParam', 'getRequest'], '', false);
     $this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface', ['loadLayout', 'getPage', 'getConfig', 'getTitle', 'loadLayoutUpdates', 'renderLayout', 'getDefaultLayoutHandle', 'generateLayoutXml', 'addPageLayoutHandles', 'generateLayoutBlocks', 'getLayout', 'addActionLayoutHandles', 'setIsLayoutLoaded', 'isLayoutLoaded'], [], '', false);
     $this->block = $this->getMock('\\Magento\\Framework\\View\\Element\\AbstractBlock', ['setActive', 'getMenuModel'], [], '', false);
     $this->layout = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\LayoutInterface', ['getBlock'], '', false);
     $this->menu = $this->getMock('\\Magento\\Backend\\Model\\Menu', ['getParentItems'], [], '', false);
     $this->items = $this->getMock('\\Magento\\Backend\\Model\\Menu\\Item', ['getParentItems'], [], '', false);
     $this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request);
     $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response);
     $this->contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->page = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', ['getConfig'], [], '', false);
     $this->config = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', ['getTitle'], [], '', false);
     $this->title = $this->getMock('\\Title', ['prepend'], [], '', false);
     $this->block->expects($this->any())->method('setActive')->will($this->returnValue(1));
     $this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
     $this->layout->expects($this->any())->method('getBlock')->with('menu')->will($this->returnValue($this->block));
     $this->block->expects($this->any())->method('getMenuModel')->will($this->returnValue($this->menu));
     $this->menu->expects($this->any())->method('getParentItems')->will($this->returnValue($this->items));
     $this->object = new \Magento\Indexer\Controller\Adminhtml\Indexer\ListAction($this->contextMock);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:27,代碼來源:ListActionTest.php


注:本文中的Magento\Framework\View\Element\AbstractBlock::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。