@@ -209,6 +209,79 @@ public function testQueryChildCategoriesWithProducts()
209
209
$ this ->assertCategoryChildren ($ secondChildCategory , $ firstChildCategoryChildren );
210
210
}
211
211
212
+ /**
213
+ * @magentoApiDataFixture Magento/Catalog/_files/categories_disabled.php
214
+ */
215
+ public function testQueryChildCategoriesWithProductsDisabled ()
216
+ {
217
+ $ query = <<<QUERY
218
+ {
219
+ categoryList(filters: {ids: {in: ["3"]}}){
220
+ id
221
+ name
222
+ url_key
223
+ url_path
224
+ description
225
+ products{
226
+ total_count
227
+ items{
228
+ name
229
+ sku
230
+ }
231
+ }
232
+ children{
233
+ name
234
+ url_key
235
+ description
236
+ products{
237
+ total_count
238
+ items{
239
+ name
240
+ sku
241
+ }
242
+ }
243
+ children{
244
+ name
245
+ }
246
+ }
247
+ }
248
+ }
249
+ QUERY ;
250
+ $ result = $ this ->graphQlQuery ($ query );
251
+
252
+ $ this ->assertArrayNotHasKey ('errors ' , $ result );
253
+ $ this ->assertCount (1 , $ result ['categoryList ' ]);
254
+ $ baseCategory = $ result ['categoryList ' ][0 ];
255
+
256
+ $ this ->assertEquals ('Category 1 ' , $ baseCategory ['name ' ]);
257
+ $ this ->assertArrayHasKey ('products ' , $ baseCategory );
258
+ //Check base category products
259
+ $ expectedBaseCategoryProducts = [
260
+ ['sku ' => 'simple ' , 'name ' => 'Simple Product ' ],
261
+ ['sku ' => '12345 ' , 'name ' => 'Simple Product Two ' ],
262
+ ['sku ' => 'simple-4 ' , 'name ' => 'Simple Product Three ' ]
263
+ ];
264
+ $ this ->assertCategoryProducts ($ baseCategory , $ expectedBaseCategoryProducts );
265
+ //Check base category children
266
+ $ expectedBaseCategoryChildren = [
267
+ ['name ' => 'Category 1.2 ' , 'description ' => 'Its a description of Test Category 1.2 ' ]
268
+ ];
269
+ $ this ->assertCategoryChildren ($ baseCategory , $ expectedBaseCategoryChildren );
270
+
271
+ //Check first child category
272
+ $ firstChildCategory = $ baseCategory ['children ' ][0 ];
273
+ $ this ->assertEquals ('Category 1.2 ' , $ firstChildCategory ['name ' ]);
274
+ $ this ->assertEquals ('Its a description of Test Category 1.2 ' , $ firstChildCategory ['description ' ]);
275
+
276
+ $ firstChildCategoryExpectedProducts = [
277
+ ['sku ' => 'simple ' , 'name ' => 'Simple Product ' ],
278
+ ['sku ' => 'simple-4 ' , 'name ' => 'Simple Product Three ' ]
279
+ ];
280
+ $ this ->assertCategoryProducts ($ firstChildCategory , $ firstChildCategoryExpectedProducts );
281
+ $ firstChildCategoryChildren = [];
282
+ $ this ->assertCategoryChildren ($ firstChildCategory , $ firstChildCategoryChildren );
283
+ }
284
+
212
285
/**
213
286
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
214
287
*/
0 commit comments