9 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
23 private $hashMapPoolMock;
26 private $dataCategoryMapMock;
31 private $collectionFactoryMock;
36 private $productCollectionMock;
43 $this->hashMapPoolMock = $this->createMock(HashMapPool::class);
44 $this->dataCategoryMapMock = $this->createMock(DataCategoryHashMap::class);
45 $this->collectionFactoryMock = $this->createPartialMock(CollectionFactory::class, [
'create']);
46 $this->productCollectionMock = $this->createPartialMock(
47 ProductCollection::class,
48 [
'getSelect',
'getConnection',
'getAllIds']
51 $this->collectionFactoryMock->expects($this->any())
53 ->willReturn($this->productCollectionMock);
55 $this->hashMapPoolMock->expects($this->any())
56 ->method(
'getDataMap')
57 ->willReturn($this->dataCategoryMapMock);
60 DataProductHashMap::class,
62 'collectionFactory' => $this->collectionFactoryMock,
63 'hashMapPool' => $this->hashMapPoolMock
73 $productIds = [
'1' => [1, 2, 3],
'2' => [2, 3],
'3' => 3];
74 $productIdsOther = [
'2' => [2, 3, 4]];
76 $connectionMock = $this->createMock(AdapterInterface::class);
77 $selectMock = $this->createMock(Select::class);
79 $this->productCollectionMock->expects($this->exactly(3))
82 $this->productCollectionMock->expects($this->any())
83 ->method(
'getConnection')
84 ->willReturn($connectionMock);
85 $connectionMock->expects($this->any())
86 ->method(
'getTableName')
87 ->willReturn($this->returnValue($this->returnArgument(0)));
88 $this->productCollectionMock->expects($this->any())
90 ->willReturn($selectMock);
91 $selectMock->expects($this->any())
94 $selectMock->expects($this->any())
97 $selectMock->expects($this->any())
100 $this->dataCategoryMapMock->expects($this->any())
101 ->method(
'getAllData')
103 $this->hashMapPoolMock->expects($this->any())
105 ->with(DataCategoryHashMap::class, 1);
106 $this->assertEquals(
$productIds, $this->model->getAllData(1));
107 $this->assertEquals(
$productIds[2], $this->model->getData(1, 2));
108 $this->assertEquals($productIdsOther, $this->model->getAllData(2));
109 $this->assertEquals($productIdsOther[2], $this->model->getData(2, 2));
110 $this->model->resetData(1);
111 $this->assertEquals(
$productIds[2], $this->model->getData(1, 2));
112 $this->assertEquals(
$productIds, $this->model->getAllData(1));