@@ -277,15 +277,57 @@ public function testAddAttributeToFilterAffectsGetSize(): void
277
277
}
278
278
279
279
/**
280
- * Add tier price attribute filter to collection
280
+ * Add tier price attribute filter to collection with different condition types.
281
281
*
282
+ * @param mixed $condition
282
283
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/few_simple_products.php
283
284
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
285
+ *
286
+ * @dataProvider addAttributeTierPriceToFilterDataProvider
287
+ */
288
+ public function testAddAttributeTierPriceToFilter ($ condition ): void
289
+ {
290
+ $ this ->collection ->addAttributeToFilter ('tier_price ' , $ condition );
291
+ $ this ->assertEquals (1 , $ this ->collection ->getSize ());
292
+ }
293
+
294
+ /**
295
+ * @return array
296
+ */
297
+ public function addAttributeTierPriceToFilterDataProvider (): array
298
+ {
299
+ return [
300
+ 'condition is array ' => [['eq ' => 8 ]],
301
+ 'condition is string ' => ['8 ' ],
302
+ 'condition is int ' => [8 ],
303
+ 'condition is null ' => [null ]
304
+ ];
305
+ }
306
+
307
+ /**
308
+ * Add is_saleable attribute filter to collection with different condition types.
309
+ *
310
+ * @param mixed $condition
311
+ * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
312
+ *
313
+ * @dataProvider addAttributeIsSaleableToFilterDataProvider
284
314
*/
285
- public function testAddAttributeTierPriceToFilter ( ): void
315
+ public function testAddAttributeIsSaleableToFilter ( $ condition ): void
286
316
{
287
- $ this ->assertEquals (11 , $ this ->collection ->getSize ());
288
- $ this ->collection ->addAttributeToFilter ('tier_price ' , ['gt ' => 0 ]);
317
+ $ this ->collection ->addAttributeToFilter ('is_saleable ' , $ condition );
289
318
$ this ->assertEquals (1 , $ this ->collection ->getSize ());
290
319
}
320
+
321
+ /**
322
+ * @return array
323
+ */
324
+ public function addAttributeIsSaleableToFilterDataProvider (): array
325
+ {
326
+ return [
327
+ 'condition is array ' => [['eq ' => 1 ]],
328
+ 'condition is string ' => ['1 ' ],
329
+ 'condition is int ' => [1 ],
330
+ 'condition is null ' => [null ]
331
+ ];
332
+ }
291
333
}
0 commit comments