@@ -37,11 +37,11 @@ function ($a) {
37
37
$ booleanAggregation = reset ($ booleanAggregation );
38
38
$ this ->assertEquals ('Boolean Attribute ' , $ booleanAggregation ['label ' ]);
39
39
$ 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 ' ]);
41
41
42
42
$ this ->assertEquals (2 , $ booleanAggregation ['count ' ]);
43
43
$ 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 ' ]);
45
45
}
46
46
47
47
/**
@@ -68,18 +68,18 @@ function ($a) {
68
68
$ this ->assertEquals ('Price ' , $ priceAggregation ['label ' ]);
69
69
$ this ->assertEquals (4 , $ priceAggregation ['count ' ]);
70
70
$ 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 ' ]
75
75
];
76
76
$ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
77
77
}
78
78
79
79
/**
80
80
* @magentoApiDataFixture Magento/Catalog/_files/products_for_search.php
81
81
* @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
83
83
*/
84
84
public function testAggregationPriceRangesWithCurrencyHeader ()
85
85
{
@@ -101,14 +101,30 @@ function ($a) {
101
101
$ this ->assertEquals ('Price ' , $ priceAggregation ['label ' ]);
102
102
$ this ->assertEquals (4 , $ priceAggregation ['count ' ]);
103
103
$ 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 ' ]
108
108
];
109
109
$ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
110
110
}
111
111
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
+
112
128
/**
113
129
* @magentoApiDataFixture Magento/Catalog/_files/products_for_search_with_custom_price_attribute.php
114
130
*/
@@ -132,8 +148,8 @@ function ($a) {
132
148
$ priceAggregation = reset ($ priceAggregation );
133
149
$ this ->assertEquals (2 , $ priceAggregation ['count ' ]);
134
150
$ 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 ' ]
137
153
];
138
154
$ this ->assertEquals ($ expectedOptions , $ priceAggregation ['options ' ]);
139
155
}
0 commit comments