12 $catalogResourceMock = $this->getMockBuilder(\
Magento\Catalog\Model\
ResourceModel\Eav\Attribute::class)
13 ->disableOriginalConstructor()
14 ->setMethods([
'load',
'isIndexable',
'__wakeup'])
16 $catalogResourceMock->expects($this->any())
18 ->will($this->returnSelf());
19 $catalogResourceMock->expects($this->at(1))
20 ->method(
'isIndexable')
21 ->will($this->returnValue(
true));
22 $catalogResourceMock->expects($this->at(2))
23 ->method(
'isIndexable')
24 ->will($this->returnValue(
false));
26 $eavAttributeFactoryMock = $this->getMockBuilder(
29 ->disableOriginalConstructor()
30 ->setMethods([
'create'])
32 $eavAttributeFactoryMock->expects($this->once())
34 ->will($this->returnValue($catalogResourceMock));
36 $attributeMock1 = $this->getMockBuilder(\
Magento\Eav\Model\Entity\Attribute::class)
37 ->disableOriginalConstructor()
38 ->setMethods([
'getId',
'getAttributeId',
'getAttributeCode',
'load',
'__wakeup'])
40 $attributeMock1->expects($this->any())
41 ->method(
'getAttributeCode')
42 ->will($this->returnValue(
'indexable_attribute'));
43 $attributeMock1->expects($this->any())
45 ->will($this->returnSelf());
47 $attributeMock2 = $this->getMockBuilder(\
Magento\Eav\Model\Entity\Attribute::class)
48 ->disableOriginalConstructor()
49 ->setMethods([
'getId',
'getAttributeId',
'getAttributeCode',
'load',
'__wakeup'])
51 $attributeMock2->expects($this->any())
52 ->method(
'getAttributeCode')
53 ->will($this->returnValue(
'non_indexable_attribute'));
54 $attributeMock2->expects($this->any())
56 ->will($this->returnSelf());
60 $groupMock = $this->getMockBuilder(\
Magento\Eav\Model\Entity\
Attribute\Group::class)
61 ->disableOriginalConstructor()
62 ->setMethods([
'getAttributes',
'__wakeup'])
64 $groupMock->expects($this->once())
65 ->method(
'getAttributes')
68 $attributeSetMock = $this->getMockBuilder(\
Magento\Eav\Model\Entity\
Attribute\Set::class)
69 ->disableOriginalConstructor()
70 ->setMethods([
'getGroups',
'__wakeup'])
72 $attributeSetMock->expects($this->once())
74 ->will($this->returnValue([$groupMock]));
76 $model = new \Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter(
77 $eavAttributeFactoryMock
80 $this->assertEquals([
'indexable_attribute'],
$model->filter($attributeSetMock));