當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。