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


PHP Category::expects方法代码示例

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


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

示例1: testAddCatalogToTopMenuItemsWithFlat

 public function testAddCatalogToTopMenuItemsWithFlat()
 {
     $observer = $this->_preparationData();
     $this->_category->expects($this->once())->method('getChildrenNodes')->will($this->returnValue([$this->_childrenCategory]));
     $this->_category->expects($this->once())->method('getUseFlatResource')->will($this->returnValue(true));
     $this->_categoryFlatState->expects($this->once())->method('isFlatEnabled')->will($this->returnValue(true));
     $this->_observer->execute($observer);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:AddCatalogToTopmenuItemsObserverTest.php

示例2: testGetUrlKey

 /**
  * @dataProvider getUrlKeyDataProvider
  * @param string|null|bool $urlKey
  * @param string|null|bool $name
  * @param string $result
  */
 public function testGetUrlKey($urlKey, $name, $result)
 {
     $this->category->expects($this->once())->method('getUrlKey')->will($this->returnValue($urlKey));
     $this->category->expects($this->any())->method('getName')->will($this->returnValue($name));
     $this->category->expects($this->once())->method('formatUrlKey')->will($this->returnArgument(0));
     $this->assertEquals($result, $this->categoryUrlPathGenerator->getUrlKey($this->category));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:CategoryUrlPathGeneratorTest.php

示例3: testGetCategoryWithAppliedId

 public function testGetCategoryWithAppliedId()
 {
     $storeId = 1234;
     $categoryId = 4321;
     $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId));
     $this->layer->expects($this->any())->method('getCurrentCategory')->will($this->returnValue($this->category));
     $this->category->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId))->will($this->returnSelf());
     $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId))->will($this->returnSelf());
     $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId));
     $this->category->expects($this->any())->method('getPathIds')->will($this->returnValue([20, 10]));
     $this->coreRegistry->expects($this->once())->method('register')->with($this->equalTo('current_category_filter'), $this->equalTo($this->category), $this->equalTo(true))->will($this->returnSelf());
     $this->target->setCategoryId($categoryId);
     $this->assertSame($this->category, $this->target->getCategory());
     $this->assertSame(20, $this->target->getResetValue());
     return $this->target;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:CategoryTest.php

示例4: testExecute

 /**
  * Run test execute method
  *
  * @param int|bool $categoryId
  * @param int $storeId
  * @return void
  *
  * @dataProvider dataProviderExecute
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecute($categoryId, $storeId)
 {
     $rootCategoryId = 2;
     $this->requestMock->expects($this->atLeastOnce())->method('getParam')->will($this->returnValueMap([['id', false, $categoryId], ['store', null, $storeId]]));
     $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->with('isAjax')->will($this->returnValue(false));
     $this->mockInitCategoryCall();
     $this->sessionMock->expects($this->once())->method('__call')->will($this->returnValue([]));
     if (!$categoryId) {
         if ($storeId) {
             $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnSelf());
         } else {
             $this->storeManagerInterfaceMock->expects($this->once())->method('getDefaultStoreView')->will($this->returnSelf());
         }
         $this->storeManagerInterfaceMock->expects($this->once())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
         $categoryId = $rootCategoryId;
     }
     $this->requestMock->expects($this->atLeastOnce())->method('setParam')->with('id', $categoryId)->will($this->returnValue(true));
     $this->categoryMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($categoryId));
     /**
      * @var \Magento\Framework\View\Element\Template
      * |\PHPUnit_Framework_MockObject_MockObject $blockMock
      */
     $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\Template', ['setStoreId'], [], '', false);
     $blockMock->expects($this->once())->method('setStoreId')->with($storeId);
     $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnSelf());
     $this->resultPageMock->expects($this->once())->method('getBlock')->willReturn($blockMock);
     $this->edit->execute();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:38,代码来源:EditTest.php

示例5: testGenerate

 public function testGenerate()
 {
     $requestPath = 'category.html';
     $targetPath = 'target-path';
     $storeId = 'store_id';
     $categoryId = 'category_id';
     $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId));
     $this->categoryUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->will($this->returnValue($requestPath));
     $this->categoryUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')->will($this->returnValue($targetPath));
     $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityId')->with($categoryId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityType')->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->assertEquals(['category.html_store_id' => $this->urlRewrite], $this->canonicalUrlRewriteGenerator->generate($storeId, $this->category));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:CanonicalUrlRewriteGeneratorTest.php

示例6: testGetCategoryId

 public function testGetCategoryId()
 {
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
     $this->registry->expects($this->at(0))->method('registry');
     $this->registry->expects($this->at(1))->method('registry')->will($this->returnValue($this->category));
     $this->assertFalse($this->model->getCategoryId());
     $this->assertEquals(10, $this->model->getCategoryId());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php

示例7: testGetCurrentCategory

 /**
  * @dataProvider currentCategoryProvider
  */
 public function testGetCurrentCategory($currentCategory)
 {
     $rootCategoryId = 333;
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($currentCategory));
     $this->category->expects($this->any())->method('load')->with($this->equalTo($rootCategoryId))->will($this->returnValue($this->category));
     $this->store->expects($this->any())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
     $result = $this->model->getCurrentCategory();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Category', $result);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:12,代码来源:LayerTest.php

示例8: testAssignedProducts

 public function testAssignedProducts()
 {
     $categoryId = 3;
     $productPosition = 1;
     $productId = $categoryId + 6;
     $productSku = "sku{$productId}";
     $productDto = $this->getMockBuilder('Magento\\Catalog\\Service\\V1\\Data\\Eav\\Category\\ProductLink')->disableOriginalConstructor()->getMock();
     /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $productObject */
     $productObject = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productObject->expects($this->once())->method('getSku')->will($this->returnValue($productSku));
     /** @var \Magento\Framework\Data\Collection\Db|\PHPUnit_Framework_MockObject_MockObject $productCollection */
     $productCollection = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\Db')->disableOriginalConstructor()->getMock();
     $productCollection->expects($this->any())->method('getItems')->will($this->returnValue([$productId => $productObject]));
     $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId));
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(true));
     $this->category->expects($this->once())->method('getProductsPosition')->will($this->returnValue([$productId => $productPosition]));
     $this->category->expects($this->once())->method('getProductCollection')->will($this->returnValue($productCollection));
     $this->productLinkBuilder->expects($this->any())->method('populateWithArray')->with($this->equalTo([ProductLink::SKU => $productSku, ProductLink::POSITION => $productPosition]))->will($this->returnValue($this->productLinkBuilder));
     $this->assertEquals([$productDto], $this->model->assignedProducts($categoryId));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:20,代码来源:ReadServiceTest.php

示例9: prepareMocksForAssign

 private function prepareMocksForAssign($categoryId, $productId = 333)
 {
     $productSku = 'sku333';
     $productsPosition = [105 => 16, 334 => 1];
     $this->productLink->expects($this->once())->method('getSku')->will($this->returnValue($productSku));
     $this->productLink->expects($this->any())->method('getPosition')->will($this->returnValue($categoryId));
     $this->categoryLoader->expects($this->once())->method('load')->with($this->equalTo($categoryId))->will($this->returnValue($this->category));
     $this->category->expects($this->once())->method('getProductsPosition')->will($this->returnValue($productsPosition));
     $newProductPositions = [$productId => $categoryId] + $productsPosition;
     $this->category->expects($this->any())->method('setPostedProducts')->with($this->equalTo($newProductPositions));
     $this->product->expects($this->once())->method('getIdBySku')->with($this->equalTo($productSku))->will($this->returnValue($productId));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:WriteServiceTest.php

示例10: testSetCurrentCategoryNotFoundException

 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Please correct the category.
  */
 public function testSetCurrentCategoryNotFoundException()
 {
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(null));
     $this->model->setCurrentCategory($this->category);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:LayerTest.php

示例11: testGetCanonicalUrlPathWithCategory

 public function testGetCanonicalUrlPathWithCategory()
 {
     $this->product->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->assertEquals('catalog/product/view/id/1/category/1', $this->productUrlPathGenerator->getCanonicalUrlPath($this->product, $this->category));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:6,代码来源:ProductUrlPathGeneratorTest.php


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