@@ -20,6 +20,16 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase
20
20
*/
21
21
protected $ attributeFactoryMock ;
22
22
23
+ /**
24
+ * @var \PHPUnit_Framework_MockObject_MockObject
25
+ */
26
+ protected $ eventManagerMock ;
27
+
28
+ /**
29
+ * @var \PHPUnit_Framework_MockObject_MockObject
30
+ */
31
+ protected $ objectFactoryMock ;
32
+
23
33
/**
24
34
* @var \PHPUnit_Framework_MockObject_MockObject
25
35
*/
@@ -53,6 +63,20 @@ protected function setUp()
53
63
'' ,
54
64
false
55
65
);
66
+ $ this ->eventManagerMock = $ this ->getMock (
67
+ '\Magento\Framework\Event\ManagerInterface ' ,
68
+ [],
69
+ [],
70
+ '' ,
71
+ false
72
+ );
73
+ $ this ->objectFactoryMock = $ this ->getMock (
74
+ '\Magento\Framework\ObjectFactory ' ,
75
+ ['create ' ],
76
+ [],
77
+ '' ,
78
+ false
79
+ );
56
80
$ this ->collectionMock = $ this ->getMock (
57
81
'Magento\Catalog\Model\Resource\Product\Attribute\Collection ' ,
58
82
[],
@@ -78,7 +102,7 @@ protected function setUp()
78
102
$ this ->returnValue ($ this ->collectionMock )
79
103
);
80
104
$ valueMap = [
81
- ['frontend_input ' , ' select ' , $ this ->collectionMock ],
105
+ ['main_table. frontend_input ' , [ ' in ' => 123 ] , $ this ->collectionMock ],
82
106
['frontend_label ' , ['like ' => $ this ->labelPart ], $ this ->collectionMock ],
83
107
['is_user_defined ' , 1 , $ this ->collectionMock ],
84
108
['is_global ' , \Magento \Catalog \Model \Resource \Eav \Attribute::SCOPE_GLOBAL , $ this ->collectionMock ],
@@ -107,12 +131,19 @@ protected function setUp()
107
131
);
108
132
$ this ->suggestedListModel = new \Magento \ConfigurableProduct \Model \SuggestedAttributeList (
109
133
$ this ->attributeFactoryMock ,
110
- $ this ->resourceHelperMock
134
+ $ this ->resourceHelperMock ,
135
+ $ this ->eventManagerMock ,
136
+ $ this ->objectFactoryMock
111
137
);
112
138
}
113
139
114
140
public function testGetSuggestedAttributesIfTheyApplicable ()
115
141
{
142
+ $ object = $ this ->getMock ('\Magento\Framework\Object ' , [], [], '' , false );
143
+ $ object ->expects ($ this ->once ())->method ('setData ' );
144
+ $ object ->expects ($ this ->once ())->method ('getData ' )->willReturn (123 );
145
+ $ this ->objectFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ object );
146
+
116
147
$ source = $ this ->getMock (
117
148
'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource ' ,
118
149
[],
@@ -132,6 +163,10 @@ public function testGetSuggestedAttributesIfTheyApplicable()
132
163
133
164
public function testGetSuggestedAttributesIfTheyNotApplicable ()
134
165
{
166
+ $ object = $ this ->getMock ('\Magento\Framework\Object ' , [], [], '' , false );
167
+ $ object ->expects ($ this ->once ())->method ('setData ' );
168
+ $ object ->expects ($ this ->once ())->method ('getData ' )->willReturn (123 );
169
+ $ this ->objectFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ object );
135
170
$ this ->attributeMock ->expects ($ this ->any ())->method ('getApplyTo ' )->will ($ this ->returnValue (['simple ' ]));
136
171
$ this ->attributeMock ->expects ($ this ->never ())->method ('getId ' );
137
172
$ this ->attributeMock ->expects ($ this ->never ())->method ('getFrontendLabel ' );
0 commit comments