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


PHP CategoryFactory::expects方法代码示例

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


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

示例1: setUp

 /**
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function setUp()
 {
     /** @var \Magento\Framework\Registry $var */
     $this->coreRegistry = $var = $this->getMockBuilder('\\Magento\\Framework\\Registry')->disableOriginalConstructor()->setMethods(['register'])->getMock();
     $this->category = $this->getMockBuilder('Magento\\Catalog\\Model\\Category')->disableOriginalConstructor()->setMethods(['getId', 'setStoreId', 'load', 'getPathIds'])->getMock();
     $this->categoryFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\CategoryFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->categoryFactory->expects($this->any())->method('create')->will($this->returnValue($this->category));
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $this->layer = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer')->disableOriginalConstructor()->setMethods(['getCurrentStore', 'getCurrentCategory'])->getMock();
     $this->layer->expects($this->any())->method('getCurrentStore')->will($this->returnValue($this->store));
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->target = $objectManagerHelper->getObject('Magento\\Catalog\\Model\\Layer\\Filter\\DataProvider\\Category', ['coreRegistry' => $this->coreRegistry, 'categoryFactory' => $this->categoryFactory, 'layer' => $this->layer]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:CategoryTest.php

示例2: setUp

 protected function setUp()
 {
     $helper = new ObjectManager($this);
     $this->category = $this->getMockBuilder('Magento\\Catalog\\Model\\Category')->setMethods(['load', 'getId', '__wakeup'])->disableOriginalConstructor()->getMock();
     $this->categoryFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\CategoryFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->categoryFactory->expects($this->any())->method('create')->will($this->returnValue($this->category));
     $this->registry = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['registry'])->disableOriginalConstructor()->getMock();
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getRootCategoryId', 'getFilters', '__wakeup'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->storeManager = $this->getMockBuilder('Magento\\Framework\\StoreManagerInterface')->setMethods(['getStore'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->stateKeyGenerator = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Category\\StateKey')->setMethods(['toString'])->disableOriginalConstructor()->getMock();
     $this->collectionFilter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Category\\CollectionFilter')->setMethods(['filter'])->disableOriginalConstructor()->getMock();
     $this->collectionProvider = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\ItemCollectionProviderInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->filter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Filter\\Item')->setMethods(['getFilter', 'getValueString'])->disableOriginalConstructor()->getMock();
     $this->abstractFilter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Filter\\AbstractFilter')->setMethods(['getRequestVar'])->disableOriginalConstructor()->getMock();
     $this->context = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\ContextInterface')->setMethods(['getStateKey', 'getCollectionFilter'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->context->expects($this->any())->method('getStateKey')->will($this->returnValue($this->stateKeyGenerator));
     $this->context->expects($this->any())->method('getCollectionFilter')->will($this->returnValue($this->collectionFilter));
     $this->context->expects($this->any())->method('getCollectionProvider')->will($this->returnValue($this->collectionProvider));
     $this->state = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\State')->disableOriginalConstructor()->getMock();
     $this->stateFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\StateFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->stateFactory->expects($this->any())->method('create')->will($this->returnValue($this->state));
     $this->collection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Collection')->disableOriginalConstructor()->getMock();
     $this->model = $helper->getObject('Magento\\Catalog\\Model\\Layer', ['registry' => $this->registry, 'categoryFactory' => $this->categoryFactory, 'storeManager' => $this->storeManager, 'context' => $this->context, 'layerStateFactory' => $this->stateFactory]);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:25,代码来源:LayerTest.php


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