12 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
36 $this->productCollection = $this->getMockBuilder(Collection::class)
37 ->disableOriginalConstructor()
39 $this->productCollectionFactory = $this->getMockBuilder(CollectionFactory::class)
40 ->setMethods([
'create'])
41 ->disableOriginalConstructor()
43 $this->productCollectionFactory->expects($this->once())->method(
'create')->willReturn($this->productCollection);
45 $this->attributeSetFinder = (
new ObjectManager($this))->getObject(
46 AttributeSetFinder::class,
48 'productCollectionFactory' => $this->productCollectionFactory,
56 $attributeSetIds = [3, 4, 6];
58 $select = $this->getMockBuilder(Select::class)
59 ->disableOriginalConstructor()
63 $select->expects($this->once())->method(
'where')->with(
'entity_id IN (?)',
$productIds)->willReturnSelf();
66 $connection = $this->createMock(AdapterInterface::class);
67 $connection->expects($this->once())->method(
'fetchCol')->with(
$select)->willReturn($attributeSetIds);
69 $this->productCollection->expects($this->once())->method(
'getSelect')->willReturn(
$select);
70 $this->productCollection->expects($this->once())->method(
'getConnection')->willReturn(
$connection);
72 $this->assertEquals($attributeSetIds, $this->attributeSetFinder->findAttributeSetIdsByProductIds(
$productIds));
$productCollectionFactory
testFindAttributeIdsByProductIds()