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


PHP PHPUnit_Framework_MockObject_MockObject::setLayout方法代码示例

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


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

示例1: testGetItems

 /**
  * @covers \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid::getItems
  */
 public function testGetItems()
 {
     $productId = 8;
     $itemQty = 23;
     $layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\AbstractBlock', ['getItems'], [], '', false);
     $itemMock = $this->getMock('Magento\\Sales\\Model\\Quote\\Item', array('getProduct', 'setHasError', 'setQty', 'getQty', '__sleep', '__wakeup'), array(), '', false);
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', array('getStockItem', 'getID', '__sleep', '__wakeup'), array(), '', false);
     $checkMock = $this->getMock('Magento\\Framework\\Object', ['getMessage', 'getHasError'], [], '', false);
     $layoutMock->expects($this->once())->method('getParentName')->will($this->returnValue('parentBlock'));
     $layoutMock->expects($this->once())->method('getBlock')->with('parentBlock')->will($this->returnValue($blockMock));
     $blockMock->expects($this->once())->method('getItems')->will($this->returnValue(array($itemMock)));
     $itemMock->expects($this->any())->method('getChildren')->will($this->returnValue(array($itemMock)));
     $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock));
     $itemMock->expects($this->any())->method('getQty')->will($this->returnValue($itemQty));
     $productMock->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $productMock->expects($this->any())->method('getStatus')->will($this->returnValue(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED));
     $checkMock->expects($this->any())->method('getMessage')->will($this->returnValue('Message'));
     $checkMock->expects($this->any())->method('getHasError')->will($this->returnValue(false));
     $this->stockItemService->expects($this->once())->method('checkQuoteItemQty')->with($this->equalTo($productId), $this->equalTo($itemQty), $this->equalTo($itemQty))->will($this->returnValue($checkMock));
     $this->block->getQuote()->setIsSuperMode(true);
     $items = $this->block->setLayout($layoutMock)->getItems();
     $this->assertEquals('Message', $items[0]->getMessage());
     $this->assertEquals(true, $this->block->getQuote()->getIsSuperMode());
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:28,代码来源:GridTest.php

示例2: testSetGetLayout

 public function testSetGetLayout()
 {
     $this->assertNull($this->_helper->getLayout());
     $this->assertInstanceof(get_class($this->_helper), $this->_helper->setLayout(Mage::app()->getLayout()));
     $this->assertInstanceOf('Mage_Core_Model_Layout', $this->_helper->getLayout());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:6,代码来源:AbstractTest.php


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