@@ -165,6 +165,42 @@ public function testExecuteWithArrayInParam(array $searchParams): void
165
165
);
166
166
}
167
167
168
+ /**
169
+ * Advanced search test by difference product attributes.
170
+ *
171
+ * @magentoAppArea frontend
172
+ * @magentoDataFixture Magento/CatalogSearch/_files/product_for_search.php
173
+ * @magentoDataFixture Magento/CatalogSearch/_files/full_reindex.php
174
+ * @dataProvider testDataForAttributesCombination
175
+ *
176
+ * @param array $searchParams
177
+ * @param bool $isProductShown
178
+ * @return void
179
+ */
180
+ public function testExecuteForAttributesCombination (array $ searchParams , bool $ isProductShown ): void
181
+ {
182
+ $ this ->getRequest ()->setQuery (
183
+ $ this ->_objectManager ->create (
184
+ Parameters::class,
185
+ [
186
+ 'values ' => $ searchParams
187
+ ]
188
+ )
189
+ );
190
+ $ this ->dispatch ('catalogsearch/advanced/result ' );
191
+ $ responseBody = $ this ->getResponse ()->getBody ();
192
+
193
+ if ($ isProductShown ) {
194
+ $ this ->assertStringContainsString ('Simple product name ' , $ responseBody );
195
+ } else {
196
+ $ this ->assertStringContainsString (
197
+ 'We can't find any items matching these search criteria. ' ,
198
+ $ responseBody
199
+ );
200
+ }
201
+ $ this ->assertStringNotContainsString ('Not visible simple product ' , $ responseBody );
202
+ }
203
+
168
204
/**
169
205
* Data provider with array in params values
170
206
*
@@ -339,4 +375,71 @@ private function getAttributeOptionValueByOptionLabel(string $attributeCode, str
339
375
340
376
return $ attribute ->getSource ()->getOptionId ($ optionLabel );
341
377
}
378
+
379
+ /**
380
+ * Data provider with strings for quick search.
381
+ *
382
+ * @return array
383
+ */
384
+ public function testDataForAttributesCombination (): array
385
+ {
386
+ return [
387
+ 'search_product_by_name_and_price ' => [
388
+ [
389
+ 'name ' => 'Simple product name ' ,
390
+ 'sku ' => '' ,
391
+ 'description ' => '' ,
392
+ 'short_description ' => '' ,
393
+ 'price ' => [
394
+ 'from ' => 99 ,
395
+ 'to ' => 101 ,
396
+ ],
397
+ 'test_searchable_attribute ' => '' ,
398
+ ],
399
+ true
400
+ ],
401
+ 'search_product_by_name_and_price_not_shown ' => [
402
+ [
403
+ 'name ' => 'Simple product name ' ,
404
+ 'sku ' => '' ,
405
+ 'description ' => '' ,
406
+ 'short_description ' => '' ,
407
+ 'price ' => [
408
+ 'from ' => 101 ,
409
+ 'to ' => 102 ,
410
+ ],
411
+ 'test_searchable_attribute ' => '' ,
412
+ ],
413
+ false
414
+ ],
415
+ 'search_product_by_sku ' => [
416
+ [
417
+ 'name ' => '' ,
418
+ 'sku ' => 'simple_for_search ' ,
419
+ 'description ' => '' ,
420
+ 'short_description ' => '' ,
421
+ 'price ' => [
422
+ 'from ' => 99 ,
423
+ 'to ' => 101 ,
424
+ ],
425
+ 'test_searchable_attribute ' => '' ,
426
+ ],
427
+ true
428
+ ],
429
+ 'search_product_by_sku_not_shown ' => [
430
+ [
431
+ 'name ' => '' ,
432
+ 'sku ' => 'simple_for_search ' ,
433
+ 'description ' => '' ,
434
+ 'short_description ' => '' ,
435
+ 'price ' => [
436
+ 'from ' => 990 ,
437
+ 'to ' => 1010 ,
438
+ ],
439
+ 'test_searchable_attribute ' => '' ,
440
+ ],
441
+ false
442
+ ],
443
+ ];
444
+ }
342
445
}
0 commit comments