@@ -114,13 +114,12 @@ public function testCategoriesTree()
114
114
}
115
115
116
116
/**
117
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
118
- * @magentoApiDataFixture Magento/Catalog/_files/categories_indexed.php
117
+ * @magentoApiDataFixture Magento/Catalog/_files/categories.php
119
118
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
120
119
*/
121
120
public function testCategoryProducts ()
122
121
{
123
- $ categoryId = 4 ;
122
+ $ categoryId = 2 ;
124
123
$ query = <<<QUERY
125
124
{
126
125
category(id: {$ categoryId }) {
@@ -266,25 +265,21 @@ public function testCategoryProducts()
266
265
$ response = $ this ->graphQlQuery ($ query );
267
266
$ this ->assertArrayHasKey ('products ' , $ response ['category ' ]);
268
267
$ this ->assertArrayHasKey ('total_count ' , $ response ['category ' ]['products ' ]);
269
- $ this ->assertEquals ( 2 , $ response ['category ' ]['products ' ]['total_count ' ]);
268
+ $ this ->assertGreaterThanOrEqual ( 1 , $ response ['category ' ]['products ' ]['total_count ' ]);
270
269
$ this ->assertEquals (1 , $ response ['category ' ]['products ' ]['page_info ' ]['current_page ' ]);
271
270
$ this ->assertEquals (20 , $ response ['category ' ]['products ' ]['page_info ' ]['page_size ' ]);
272
271
272
+ $ this ->assertArrayHasKey ('sku ' , $ response ['category ' ]['products ' ]['items ' ][0 ]);
273
+ $ firstProductSku = $ response ['category ' ]['products ' ]['items ' ][0 ]['sku ' ];
274
+
273
275
/**
274
276
* @var ProductRepositoryInterface $productRepository
275
277
*/
276
278
$ productRepository = ObjectManager::getInstance ()->get (ProductRepositoryInterface::class);
277
- $ firstProductSku = 'simple ' ;
278
279
$ firstProduct = $ productRepository ->get ($ firstProductSku , false , null , true );
279
280
$ this ->assertBaseFields ($ firstProduct , $ response ['category ' ]['products ' ]['items ' ][0 ]);
280
281
$ this ->assertAttributes ($ response ['category ' ]['products ' ]['items ' ][0 ]);
281
282
$ this ->assertWebsites ($ firstProduct , $ response ['category ' ]['products ' ]['items ' ][0 ]['websites ' ]);
282
-
283
- $ secondProductSku = '12345 ' ;
284
- $ secondProduct = $ productRepository ->get ($ secondProductSku , false , null , true );
285
- $ this ->assertBaseFields ($ secondProduct , $ response ['category ' ]['products ' ]['items ' ][1 ]);
286
- $ this ->assertAttributes ($ response ['category ' ]['products ' ]['items ' ][1 ]);
287
- $ this ->assertWebsites ($ secondProduct , $ response ['category ' ]['products ' ]['items ' ][1 ]['websites ' ]);
288
283
}
289
284
290
285
/**
@@ -297,7 +292,6 @@ private function assertBaseFields($product, $actualResponse)
297
292
$ assertionMap = [
298
293
['response_field ' => 'attribute_set_id ' , 'expected_value ' => $ product ->getAttributeSetId ()],
299
294
['response_field ' => 'created_at ' , 'expected_value ' => $ product ->getCreatedAt ()],
300
- ['response_field ' => 'id ' , 'expected_value ' => $ product ->getId ()],
301
295
['response_field ' => 'name ' , 'expected_value ' => $ product ->getName ()],
302
296
['response_field ' => 'price ' , 'expected_value ' =>
303
297
[
0 commit comments