Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ItemCollectionProviderTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class ItemCollectionProviderTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testGetCollection()
14  {
15  $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
16 
17  $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
18  $collectionMock->expects($this->once())->method('addCategoryFilter')->with($categoryMock);
19 
20  $collectionFactoryMock = $this->createPartialMock(
21  \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class,
22  ['create']
23  );
24  $collectionFactoryMock->expects($this->any())->method('create')->will($this->returnValue($collectionMock));
25 
26  $objectManager = new ObjectManagerHelper($this);
27  $provider = $objectManager->getObject(
28  \Magento\CatalogSearch\Model\Layer\Category\ItemCollectionProvider::class,
29  ['collectionFactory' => $collectionFactoryMock]
30  );
31 
32  $provider->getCollection($categoryMock);
33  }
34 }
$objectManager
Definition: bootstrap.php:17