当前位置: 首页>>代码示例>>PHP>>正文


PHP LayoutInterface::expects方法代码示例

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


在下文中一共展示了LayoutInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetBlock

 public function testGetBlock()
 {
     $blockName = 'block.name';
     $block = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface');
     $this->layout->expects($this->once())->method('getBlock')->with($blockName)->will($this->returnValue($block));
     $this->assertEquals($block, $this->model->getBlock($blockName));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:LayoutTest.php

示例2: testPrepareElementHtml

 /**
  * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml
  * @param string $elementValue
  * @param integer|null $modelBlockId
  *
  * @dataProvider prepareElementHtmlDataProvider
  */
 public function testPrepareElementHtml($elementValue, $modelBlockId)
 {
     $elementId = 1;
     $uniqId = '126hj4h3j73hk7b347jhkl37gb34';
     $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
     $config = ['key1' => 'value1'];
     $fieldsetId = 2;
     $html = 'some html';
     $title = 'some title';
     $this->this->setConfig($config);
     $this->this->setFieldsetId($fieldsetId);
     $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId);
     $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId);
     $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/block_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl);
     $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock);
     $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf();
     $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue);
     $this->blockFactoryMock->expects($this->any())->method('create')->willReturn($this->modelBlockMock);
     $this->modelBlockMock->expects($this->any())->method('load')->with($elementValue)->willReturnSelf();
     $this->modelBlockMock->expects($this->any())->method('getId')->willReturn($modelBlockId);
     $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title);
     $this->chooserMock->expects($this->any())->method('setLabel')->with($title)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html);
     $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf();
     $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:ChooserTest.php

示例3: testGetGridHtml

 public function testGetGridHtml()
 {
     $html = '<body></body>';
     $this->layoutMock->expects($this->any())->method('getChildName')->willReturn('userGrid');
     $this->layoutMock->expects($this->any())->method('renderElement')->willReturn($html);
     $this->model->setLayout($this->layoutMock);
     $this->assertEquals($html, $this->model->getGridHtml());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:UsersTest.php

示例4: testAddBreadcrumbNoBlock

 public function testAddBreadcrumbNoBlock()
 {
     $label = 'label';
     $title = 'title';
     $this->layoutMock->expects($this->once())->method('getBlock')->with('breadcrumbs')->willReturn(false);
     $this->breadcrumbsBlockMock->expects($this->never())->method('addLink');
     $this->assertSame($this->resultPage, $this->resultPage->addBreadcrumb($label, $title));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:PageTest.php

示例5: testPrepareLayoutSuccessOnFalseGetId

 public function testPrepareLayoutSuccessOnFalseGetId()
 {
     $tab = 'tab';
     $this->registryMock->expects($this->once())->method('registry')->willReturn($this->layoutInterfaceMock);
     $this->layoutInterfaceMock->expects($this->any())->method('createBlock')->willReturnSelf();
     $this->layoutInterfaceMock->expects($this->once())->method('setRole')->willReturnSelf();
     $this->layoutInterfaceMock->expects($this->once())->method('setActive')->willReturn($tab);
     $this->layoutInterfaceMock->expects($this->once())->method('getId')->willReturn(false);
     $this->assertInstanceOf('Magento\\Backend\\Block\\Widget\\Tabs', $this->invokeMethod($this->model, '_prepareLayout'));
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:10,代码来源:EditTest.php

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

示例7: 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

示例8: testGetProductPriceHtmlCreateBlock

 public function testGetProductPriceHtmlCreateBlock()
 {
     $priceType = 'wishlist_configured_price';
     $expected = 'block content';
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $renderMock = $this->getMockBuilder('\\Magento\\Framework\\Pricing\\Render')->disableOriginalConstructor()->getMock();
     $renderMock->expects($this->once())->method('render')->with($priceType, $productMock, ['zone' => Render::ZONE_ITEM_LIST])->willReturn($expected);
     $this->layout->expects($this->once())->method('getBlock')->with('product.price.render.default')->willReturn(false);
     $this->layout->expects($this->once())->method('createBlock')->with('Magento\\Framework\\Pricing\\Render', 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']])->willReturn($renderMock);
     $result = $this->block->getProductPriceHtml($productMock, $priceType, Render::ZONE_ITEM_LIST);
     $this->assertEquals($expected, $result);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:SidebarTest.php

示例9: testExecute

 /**
  * @param mixed $result
  * @param string[] $responseArray
  * @dataProvider executeDataProvider
  */
 public function testExecute($result, $responseArray)
 {
     $getParamMap = [['variable_id', null, null], ['store', 0, 0]];
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap($getParamMap);
     $this->requestMock->expects($this->any())->method('getPost')->with('variable')->will($this->returnValue([]));
     $this->variableMock->expects($this->any())->method('validate')->willReturn($result);
     if ($result instanceof \Magento\Framework\Phrase) {
         $this->messageManagerMock->expects($this->once())->method('addError')->with($result->getText());
         $this->layoutMock->expects($this->once())->method('initMessages');
     }
     $this->resultJsonMock->expects($this->once())->method('setData')->with($responseArray);
     $this->validateMock->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:ValidateTest.php

示例10: setUp

 protected function setUp()
 {
     $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $this->_columnSetMock = $this->_getColumnSetMock();
     $returnValueMap = [['grid', 'grid.columnSet', 'grid.columnSet'], ['grid', 'reset_filter_button', 'reset_filter_button'], ['grid', 'search_button', 'search_button']];
     $this->_layoutMock->expects($this->any())->method('getChildName')->will($this->returnValueMap($returnValueMap));
     $this->_layoutMock->expects($this->any())->method('getBlock')->with('grid.columnSet')->will($this->returnValue($this->_columnSetMock));
     $this->_layoutMock->expects($this->any())->method('createBlock')->with('Magento\\Backend\\Block\\Widget\\Button')->will($this->returnValue(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\Widget\\Button')));
     $this->_layoutMock->expects($this->any())->method('helper')->with('Magento\\Framework\\Json\\Helper\\Data')->will($this->returnValue(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Json\\Helper\\Data')));
     $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\Widget\\Grid');
     $this->_block->setLayout($this->_layoutMock);
     $this->_block->setNameInLayout('grid');
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:13,代码来源:GridTest.php

示例11: initLayoutMock

 private function initLayoutMock()
 {
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->viewMock->expects($this->once())->method('loadLayout')->willReturnSelf();
     $this->viewMock->expects($this->once())->method('renderLayout')->willReturnSelf();
     $this->layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->blockMock));
 }
开发者ID:Zash22,项目名称:magento,代码行数:7,代码来源:ReturnUrlTest.php

示例12: testGetProductPriceHtml

 public function testGetProductPriceHtml()
 {
     $id = 6;
     $expectedHtml = '
     <div class="price-box price-final_price">
         <span class="regular-price" id="product-price-' . $id . '">
             <span class="price">$0.00</span>
         </span>
     </div>';
     $type = 'widget-new-list';
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId'], [], '', false, false);
     $productMock->expects($this->once())->method('getId')->willReturn($id);
     $arguments = ['price_id' => 'old-price-' . $id . '-' . $type, 'display_minimal_price' => true, 'include_container' => true, 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST];
     $priceBoxMock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['render'], [], '', false, false);
     $this->layout->expects($this->once())->method('getBlock')->with($this->equalTo('product.price.render.default'))->willReturn($priceBoxMock);
     $priceBoxMock->expects($this->once())->method('render')->with($this->equalTo('final_price'), $this->equalTo($productMock), $this->equalTo($arguments))->willReturn($expectedHtml);
     $result = $this->block->getProductPriceHtml($productMock, $type);
     $this->assertEquals($expectedHtml, $result);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:19,代码来源:NewWidgetTest.php

示例13: setUp

 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->requestMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\App\\RequestInterface', ['isDispatched', 'initForward', 'setDispatched', 'isForwarded']);
     $this->breadcrumbsBlockMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\View\\Element\\BlockInterface', ['addLink']);
     $this->menuBlockMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\View\\Element\\BlockInterface', ['setActive', 'getMenuModel']);
     $this->viewMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\App\\ViewInterface');
     $this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->disableOriginalConstructor()->getMock();
     $this->switcherBlockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\BlockInterface')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http\\FileFactory')->disableOriginalConstructor()->getMock();
     $this->menuModelMock = $this->getMockBuilder('Magento\\Backend\\Model\\Menu')->disableOriginalConstructor()->getMock();
     $this->abstractBlockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->setMethods(['getCsvFile', 'getExcelFile', 'setSaveParametersInSession', 'getCsv', 'getExcel'])->disableOriginalConstructor()->getMock();
     $this->menuModelMock->expects($this->any())->method('getParentItems')->willReturn([]);
     $this->menuBlockMock->expects($this->any())->method('getMenuModel')->willReturn($this->menuModelMock);
     $this->viewMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getView')->willReturn($this->viewMock);
     $this->layoutMock->expects($this->any())->method('getBlock')->will($this->returnValueMap([['breadcrumbs', $this->breadcrumbsBlockMock], ['menu', $this->menuBlockMock], ['store_switcher', $this->switcherBlockMock]]));
     $this->layoutMock->expects($this->any())->method('getChildBlock')->willReturn($this->abstractBlockMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:AbstractControllerTest.php

示例14: testToHtml

 public function testToHtml()
 {
     $childNameOne = 'child.1';
     $childNameTextOne = 'child.1 text';
     $childNameTwo = 'child.2';
     $childNames = [$childNameOne, $childNameTwo];
     $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
     /**
      * @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock
      */
     $itemMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Item')->disableOriginalConstructor()->getMock();
     $this->model->setItem($itemMock);
     $this->layoutMock->expects($this->once())->method('getChildNames')->with($this->model->getNameInLayout())->willReturn($childNames);
     /** @var Generic|\PHPUnit_Framework_MockObject_MockObject $childMockOne */
     $childMockOne = $this->getMockBuilder('Magento\\Checkout\\Block\\Cart\\Item\\Renderer\\Actions\\Generic')->disableOriginalConstructor()->getMock();
     $childMockOne->expects($this->once())->method('setItem')->with($itemMock);
     $childMockTwo = false;
     $this->layoutMock->expects($this->once())->method('renderElement')->with($childNameOne, false)->willReturn($childNameTextOne);
     $this->layoutMock->expects($this->exactly(2))->method('getBlock')->willReturnMap([[$childNameOne, $childMockOne], [$childNameTwo, $childMockTwo]]);
     $this->assertEquals($childNameTextOne, $this->model->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:ActionsTest.php

示例15: testCountrySelect

 public function testCountrySelect()
 {
     $html = "<select>";
     $default = 'default';
     $name = 'US';
     $id = '3';
     $title = "United States";
     $directoryDataMock = $this->getMockBuilder('\\Magento\\Braintree\\Block\\Directory\\Data')->disableOriginalConstructor()->getMock();
     $this->layoutMock->expects($this->any())->method('getChildName')->willReturn(true);
     $this->layoutMock->expects($this->any())->method('getBlock')->willReturn($directoryDataMock);
     $directoryDataMock->expects($this->once())->method('getCountryHtmlSelect')->with($default, $name, $id, $title)->willReturn($html);
     $this->assertEquals($html, $this->block->countrySelect($name, $id, $default, $title));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:ManagementTest.php


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