@@ -37,11 +37,11 @@ function ($a) {
3737 $ booleanAggregation = reset ($ booleanAggregation );
3838 $ this ->assertEquals ('Boolean Attribute ' , $ booleanAggregation ['label ' ]);
3939 $ this ->assertEquals ('boolean_attribute ' , $ booleanAggregation ['attribute_code ' ]);
40- $ this ->assertContainsEquals (['label ' => '1 ' , 'value ' => '1 ' , 'count ' => '3 ' ], $ booleanAggregation ['options ' ]);
40+ $ this ->assertContainsEquals (['label ' => '1 ' , 'value ' => '1 ' , 'count ' => '3 ' ], $ booleanAggregation ['options ' ]);
4141
4242 $ this ->assertEquals (2 , $ booleanAggregation ['count ' ]);
4343 $ this ->assertCount (2 , $ booleanAggregation ['options ' ]);
44- $ this ->assertContainsEquals (['label ' => '0 ' , 'value ' => '0 ' , 'count ' => '2 ' ], $ booleanAggregation ['options ' ]);
44+ $ this ->assertContainsEquals (['label ' => '0 ' , 'value ' => '0 ' , 'count ' => '2 ' ], $ booleanAggregation ['options ' ]);
4545 }
4646
4747 /**
@@ -68,18 +68,18 @@ function ($a) {
6868 $ this ->assertEquals ('Price ' , $ priceAggregation ['label ' ]);
6969 $ this ->assertEquals (4 , $ priceAggregation ['count ' ]);
7070 $ expectedOptions = [
71- ['label ' => '10-20 ' , 'value ' => '10_20 ' , 'count ' => '2 ' ],
72- ['label ' => '20-30 ' , 'value ' => '20_30 ' , 'count ' => '1 ' ],
73- ['label ' => '30-40 ' , 'value ' => '30_40 ' , 'count ' => '1 ' ],
74- ['label ' => '40-50 ' , 'value ' => '40_50 ' , 'count ' => '1 ' ]
71+ ['label ' => '10-20 ' , 'value ' => '10_20 ' , 'count ' => '2 ' ],
72+ ['label ' => '20-30 ' , 'value ' => '20_30 ' , 'count ' => '1 ' ],
73+ ['label ' => '30-40 ' , 'value ' => '30_40 ' , 'count ' => '1 ' ],
74+ ['label ' => '40-50 ' , 'value ' => '40_50 ' , 'count ' => '1 ' ]
7575 ];
7676 $ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
7777 }
7878
7979 /**
8080 * @magentoApiDataFixture Magento/Catalog/_files/products_for_search.php
8181 * @magentoApiDataFixture Magento/Directory/_files/usd_cny_rate.php
82- * @magentoConfigFixture default_store currency/options/allow CNY,USD
82+ * @magentoConfigFixture default_store currency/options/allow CNY,USD,EUR
8383 */
8484 public function testAggregationPriceRangesWithCurrencyHeader ()
8585 {
@@ -101,14 +101,30 @@ function ($a) {
101101 $ this ->assertEquals ('Price ' , $ priceAggregation ['label ' ]);
102102 $ this ->assertEquals (4 , $ priceAggregation ['count ' ]);
103103 $ expectedOptions = [
104- ['label ' => '70-140 ' , 'value ' => '70_140 ' , 'count ' => '2 ' ],
105- ['label ' => '140-210 ' , 'value ' => '140_210 ' , 'count ' => '1 ' ],
106- ['label ' => '210-280 ' , 'value ' => '210_280 ' , 'count ' => '1 ' ],
107- ['label ' => '280-350 ' , 'value ' => '280_350 ' , 'count ' => '1 ' ]
104+ ['label ' => '70-140 ' , 'value ' => '70_140 ' , 'count ' => '2 ' ],
105+ ['label ' => '140-210 ' , 'value ' => '140_210 ' , 'count ' => '1 ' ],
106+ ['label ' => '210-280 ' , 'value ' => '210_280 ' , 'count ' => '1 ' ],
107+ ['label ' => '280-350 ' , 'value ' => '280_350 ' , 'count ' => '1 ' ]
108108 ];
109109 $ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
110110 }
111111
112+ /**
113+ * @magentoApiDataFixture Magento/Catalog/_files/products_for_search.php
114+ * @magentoConfigFixture default_store currency/options/allow USD,EUR
115+ */
116+ public function testEmptyAggregationsForNotFoundProducts ()
117+ {
118+ $ headerMap ['Content-Currency ' ] = 'USD ' ;
119+ $ query = $ this ->getGraphQlQuery (
120+ '"search_product_9999", "search_product_8888" '
121+ );
122+ $ result = $ this ->graphQlQuery ($ query , [], '' , $ headerMap );
123+ $ this ->assertArrayNotHasKey ('errors ' , $ result );
124+ $ this ->assertArrayHasKey ('aggregations ' , $ result ['products ' ]);
125+ $ this ->assertEmpty ($ result ['products ' ]['aggregations ' ]);
126+ }
127+
112128 /**
113129 * @magentoApiDataFixture Magento/Catalog/_files/products_for_search_with_custom_price_attribute.php
114130 */
@@ -132,8 +148,8 @@ function ($a) {
132148 $ priceAggregation = reset ($ priceAggregation );
133149 $ this ->assertEquals (2 , $ priceAggregation ['count ' ]);
134150 $ expectedOptions = [
135- ['label ' => '0_1000 ' , 'value ' => '0_1000 ' , 'count ' => '3 ' ],
136- ['label ' => '1000_2000 ' , 'value ' => '1000_2000 ' , 'count ' => '2 ' ]
151+ ['label ' => '0_1000 ' , 'value ' => '0_1000 ' , 'count ' => '3 ' ],
152+ ['label ' => '1000_2000 ' , 'value ' => '1000_2000 ' , 'count ' => '2 ' ]
137153 ];
138154 $ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
139155 }
0 commit comments