@@ -77,12 +77,32 @@ protected function setUp()
77
77
* @param boolean $cacheEnabled
78
78
* @param int $loadCalls
79
79
* @param string $cachedValue
80
- * @param array $factoryCalls
81
80
* @dataProvider getAttributeCacheDataProvider
82
81
* @return void
83
82
*/
84
- public function testGetAttributeCache ($ cacheEnabled , $ loadCalls , $ cachedValue, $ factoryCalls )
83
+ public function testGetAttributeCache ($ cacheEnabled , $ loadCalls , $ cachedValue )
85
84
{
85
+ $ attributeCollectionMock = $ this ->getMockBuilder ('Magento\Eav\Model\Resource\Entity\Attribute\Collection ' )
86
+ ->disableOriginalConstructor ()
87
+ ->setMethods (['getData ' , 'setEntityTypeFilter ' ])
88
+ ->getMock ();
89
+ $ attributeCollectionMock
90
+ ->expects ($ this ->any ())
91
+ ->method ('setEntityTypeFilter ' )
92
+ ->will ($ this ->returnSelf ());
93
+ $ attributeCollectionMock
94
+ ->expects ($ this ->any ())
95
+ ->method ('getData ' )
96
+ ->willReturn ([]);
97
+ $ entityAttributeMock = $ this ->getMockBuilder ('Magento\Eav\Model\Entity\Attribute ' )
98
+ ->setMethods (['dummy ' ])
99
+ ->disableOriginalConstructor ()
100
+ ->getMock ();
101
+ $ factoryCalls = [
102
+ ['Magento\Eav\Model\Resource\Entity\Attribute\Collection ' , [], $ attributeCollectionMock ],
103
+ ['Magento\Eav\Model\Entity\Attribute ' , [], $ entityAttributeMock ],
104
+ ];
105
+
86
106
$ this ->stateMock
87
107
->expects ($ this ->atLeastOnce ())
88
108
->method ('isEnabled ' )
@@ -95,7 +115,7 @@ public function testGetAttributeCache($cacheEnabled, $loadCalls, $cachedValue, $
95
115
->willReturn ($ cachedValue );
96
116
97
117
$ collectionStub = new Object ([
98
- ['entity_type_code ' => 'type_code_1 ' , 'entity_type_id ' => 1 ]
118
+ ['entity_type_code ' => 'type_code_1 ' , 'entity_type_id ' => 1 ],
99
119
]);
100
120
$ this ->collectionFactoryMock
101
121
->expects ($ this ->any ())
@@ -108,7 +128,7 @@ public function testGetAttributeCache($cacheEnabled, $loadCalls, $cachedValue, $
108
128
->willReturn (new Object (['id ' => 101 ]));
109
129
110
130
$ this ->universalFactoryMock
111
- ->expects ($ this ->exactly ( count ( $ factoryCalls ) ))
131
+ ->expects ($ this ->atLeastOnce ( ))
112
132
->method ('create ' )
113
133
->will ($ this ->returnValueMap ($ factoryCalls ));
114
134
@@ -125,54 +145,26 @@ public function testGetAttributeCache($cacheEnabled, $loadCalls, $cachedValue, $
125
145
*/
126
146
public function getAttributeCacheDataProvider ()
127
147
{
128
- $ attributeCollectionMock = $ this ->getMockBuilder ('Magento\Eav\Model\Resource\Entity\Attribute\Collection ' )
129
- ->disableOriginalConstructor ()
130
- ->setMethods (['getData ' , 'setEntityTypeFilter ' ])
131
- ->getMock ();
132
- $ attributeCollectionMock
133
- ->expects ($ this ->any ())
134
- ->method ('setEntityTypeFilter ' )
135
- ->will ($ this ->returnSelf ());
136
- $ attributeCollectionMock
137
- ->expects ($ this ->any ())
138
- ->method ('getData ' )
139
- ->willReturn ([]);
140
- $ entityAttributeMock = $ this ->getMockBuilder ('Magento\Eav\Model\Entity\Attribute ' )
141
- ->setMethods (['dummy ' ])
142
- ->disableOriginalConstructor ()
143
- ->getMock ();
144
-
145
148
return [
146
149
'cache-disabled ' => [
147
150
false ,
148
151
0 ,
149
152
false ,
150
- [
151
- ['Magento\Eav\Model\Resource\Entity\Attribute\Collection ' , [], $ attributeCollectionMock ],
152
- ['Magento\Eav\Model\Entity\Attribute ' , [], $ entityAttributeMock ]
153
- ]
154
153
],
155
154
'cache-miss ' => [
156
155
true ,
157
156
1 ,
158
157
false ,
159
- [
160
- ['Magento\Eav\Model\Resource\Entity\Attribute\Collection ' , [], $ attributeCollectionMock ],
161
- ['Magento\Eav\Model\Entity\Attribute ' , [], $ entityAttributeMock ]
162
- ]
163
158
],
164
159
'cached ' => [
165
160
true ,
166
161
1 ,
167
162
serialize (
168
163
[
169
- ['attribute_code ' => 'attribute_code_1 ' , 'attribute_id ' => 1 ]
164
+ ['attribute_code ' => 'attribute_code_1 ' , 'attribute_id ' => 1 ],
170
165
]
171
166
),
172
- [
173
- ['Magento\Eav\Model\Entity\Attribute ' , [], $ entityAttributeMock ]
174
- ]
175
- ]
167
+ ],
176
168
];
177
169
}
178
170
@@ -185,7 +177,7 @@ public function testClear()
185
177
$ this ->equalTo (
186
178
[
187
179
\Magento \Eav \Model \Cache \Type::CACHE_TAG ,
188
- \Magento \Eav \Model \Entity \Attribute::CACHE_TAG
180
+ \Magento \Eav \Model \Entity \Attribute::CACHE_TAG ,
189
181
]
190
182
)
191
183
);
0 commit comments