@@ -203,9 +203,9 @@ public function testProcessPrice()
203
203
public function processCategoryIdsDataProvider ()
204
204
{
205
205
return [
206
- ['5 ' , 'category_ids_index .category_id = 5 ' ],
207
- [3 , 'category_ids_index .category_id = 3 ' ],
208
- ["' and 1 = 0 " , 'category_ids_index .category_id = 0 ' ],
206
+ ['5 ' , ':alias .category_id = 5 ' ],
207
+ [3 , ':alias .category_id = 3 ' ],
208
+ ["' and 1 = 0 " , ':alias .category_id = 0 ' ],
209
209
];
210
210
}
211
211
@@ -218,7 +218,11 @@ public function testProcessCategoryIds($categoryId, $expectedResult)
218
218
{
219
219
$ isNegation = false ;
220
220
$ query = 'SELECT category_ids FROM catalog_product_entity ' ;
221
+ $ tableAlias = 'category__alias ' ;
221
222
223
+ $ this ->aliasResolver ->expects ($ this ->atLeastOnce ())
224
+ ->method ('getAlias ' )
225
+ ->willReturn ($ tableAlias );
222
226
$ this ->filter ->expects ($ this ->exactly (3 ))
223
227
->method ('getField ' )
224
228
->will ($ this ->returnValue ('category_ids ' ));
@@ -233,9 +237,35 @@ public function testProcessCategoryIds($categoryId, $expectedResult)
233
237
->will ($ this ->returnValue ($ this ->attribute ));
234
238
235
239
$ actualResult = $ this ->target ->process ($ this ->filter , $ isNegation , $ query );
240
+ $ expectedResult = strtr ($ expectedResult , [':alias ' => $ tableAlias ]);
236
241
$ this ->assertSame ($ expectedResult , $ this ->removeWhitespaces ($ actualResult ));
237
242
}
238
243
244
+ public function testProcessVisibilityIds ()
245
+ {
246
+ $ query = 'visibility in (1, 2) ' ;
247
+ $ tableAlias = 'visibility__alias ' ;
248
+
249
+ $ this ->aliasResolver ->expects ($ this ->atLeastOnce ())
250
+ ->method ('getAlias ' )
251
+ ->willReturn ($ tableAlias );
252
+ $ this ->filter ->expects ($ this ->atLeastOnce ())
253
+ ->method ('getField ' )
254
+ ->will ($ this ->returnValue ('visibility ' ));
255
+ $ this ->filter ->expects ($ this ->never ())
256
+ ->method ('getValue ' );
257
+ $ this ->config ->expects ($ this ->once ())
258
+ ->method ('getAttribute ' )
259
+ ->with (\Magento \Catalog \Model \Product::ENTITY , 'visibility ' )
260
+ ->will ($ this ->returnValue ($ this ->attribute ));
261
+
262
+ $ actualResult = $ this ->target ->process ($ this ->filter , false , $ query );
263
+ $ this ->assertSame (
264
+ "$ tableAlias. $ query " ,
265
+ $ this ->removeWhitespaces ($ actualResult )
266
+ );
267
+ }
268
+
239
269
public function testProcessStaticAttribute ()
240
270
{
241
271
$ expectedResult = 'attr_table_alias.static_attribute LIKE %name% ' ;
@@ -246,7 +276,7 @@ public function testProcessStaticAttribute()
246
276
->willReturn ('static_attribute ' );
247
277
$ this ->aliasResolver ->expects ($ this ->once ())->method ('getAlias ' )
248
278
->willReturn ('attr_table_alias ' );
249
- $ this ->filter ->expects ($ this ->exactly (3 ))
279
+ $ this ->filter ->expects ($ this ->exactly (4 ))
250
280
->method ('getField ' )
251
281
->will ($ this ->returnValue ('static_attribute ' ));
252
282
$ this ->config ->expects ($ this ->exactly (1 ))
@@ -285,7 +315,7 @@ public function testProcessTermFilter($frontendInput, $fieldValue, $isNegation,
285
315
$ this ->aliasResolver ->expects ($ this ->once ())->method ('getAlias ' )
286
316
->willReturn ('termAttrAlias ' );
287
317
288
- $ this ->filter ->expects ($ this ->exactly (3 ))
318
+ $ this ->filter ->expects ($ this ->exactly (4 ))
289
319
->method ('getField ' )
290
320
->willReturn ('termField ' );
291
321
$ this ->filter ->expects ($ this ->exactly (2 ))
@@ -360,7 +390,7 @@ public function testProcessNotStaticAttribute()
360
390
$ attributeId = 1234567 ;
361
391
362
392
$ this ->scope ->expects ($ this ->once ())->method ('getId ' )->will ($ this ->returnValue ($ scopeId ));
363
- $ this ->filter ->expects ($ this ->exactly (4 ))
393
+ $ this ->filter ->expects ($ this ->exactly (5 ))
364
394
->method ('getField ' )
365
395
->will ($ this ->returnValue ('not_static_attribute ' ));
366
396
$ this ->config ->expects ($ this ->exactly (1 ))
0 commit comments