Skip to content

Commit 18fe48c

Browse files
author
Alex Paliarush
committed
ENGCOM-1663: Include 'products' in category query #48
1 parent 2cb9aaf commit 18fe48c

File tree

3 files changed

+6
-48
lines changed

3 files changed

+6
-48
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,12 @@ public function testCategoriesTree()
114114
}
115115

116116
/**
117-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
118-
* @magentoApiDataFixture Magento/Catalog/_files/categories_indexed.php
117+
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
119118
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
120119
*/
121120
public function testCategoryProducts()
122121
{
123-
$categoryId = 4;
122+
$categoryId = 2;
124123
$query = <<<QUERY
125124
{
126125
category(id: {$categoryId}) {
@@ -266,25 +265,21 @@ public function testCategoryProducts()
266265
$response = $this->graphQlQuery($query);
267266
$this->assertArrayHasKey('products', $response['category']);
268267
$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']);
270269
$this->assertEquals(1, $response['category']['products']['page_info']['current_page']);
271270
$this->assertEquals(20, $response['category']['products']['page_info']['page_size']);
272271

272+
$this->assertArrayHasKey('sku', $response['category']['products']['items'][0]);
273+
$firstProductSku = $response['category']['products']['items'][0]['sku'];
274+
273275
/**
274276
* @var ProductRepositoryInterface $productRepository
275277
*/
276278
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
277-
$firstProductSku = 'simple';
278279
$firstProduct = $productRepository->get($firstProductSku, false, null, true);
279280
$this->assertBaseFields($firstProduct, $response['category']['products']['items'][0]);
280281
$this->assertAttributes($response['category']['products']['items'][0]);
281282
$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']);
288283
}
289284

290285
/**
@@ -297,7 +292,6 @@ private function assertBaseFields($product, $actualResponse)
297292
$assertionMap = [
298293
['response_field' => 'attribute_set_id', 'expected_value' => $product->getAttributeSetId()],
299294
['response_field' => 'created_at', 'expected_value' => $product->getCreatedAt()],
300-
['response_field' => 'id', 'expected_value' => $product->getId()],
301295
['response_field' => 'name', 'expected_value' => $product->getName()],
302296
['response_field' => 'price', 'expected_value' =>
303297
[

dev/tests/integration/testsuite/Magento/Catalog/_files/categories_indexed.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Catalog/_files/categories_indexed_rollback.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)