Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 7fac89a

Browse files
authored
Merge pull request #3048 from magento-epam/EPAM-PR-3
[epam] MAGETWO-91620: It is not possible to use function setInAllAttributeSetsFilter() together with getAllIds() for class \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection
2 parents 498d679 + 3ef35a7 commit 7fac89a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function setInAllAttributeSetsFilter(array $setIds)
222222
$setIds
223223
)
224224
->group('entity_attribute.attribute_id')
225-
->having('count = ' . count($setIds));
225+
->having(new \Zend_Db_Expr('COUNT(*)') . ' = ' . count($setIds));
226226
}
227227

228228
//$this->getSelect()->distinct(true);

app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ public function testSetInAllAttributeSetsFilter()
150150
$this->selectMock->expects($this->atLeastOnce())->method('group')->with('entity_attribute.attribute_id')
151151
->willReturnSelf();
152152

153-
$this->selectMock->expects($this->atLeastOnce())->method('having')->with('count = ' . count($setIds))
154-
->willReturnSelf();
153+
$this->selectMock->expects($this->atLeastOnce())->method('having')
154+
->with(new \Zend_Db_Expr('COUNT(*)') . ' = ' . count($setIds))->willReturnSelf();
155155

156156
$this->model->setInAllAttributeSetsFilter($setIds);
157157
}

dev/tests/integration/testsuite/Magento/Eav/Model/ResourceModel/Entity/Attribute/CollectionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ public function testSetAttributeGroupFilter()
5252
$this->assertEquals([$includeGroupId], $groups);
5353
}
5454

55+
/**
56+
* Test if getAllIds method return results after using setInAllAttributeSetsFilter method
57+
*
58+
* @covers \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::setInAllAttributeSetsFilter()
59+
* @covers \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::getAllIds()
60+
*/
61+
public function testSetInAllAttributeSetsFilterWithGetAllIds()
62+
{
63+
$sets = [1];
64+
$this->_model->setInAllAttributeSetsFilter($sets);
65+
$attributeIds = $this->_model->getAllIds();
66+
$this->assertGreaterThan(0, count($attributeIds));
67+
}
68+
5569
/**
5670
* Returns array of group ids, present in collection attributes
5771
*

0 commit comments

Comments
 (0)