Skip to content

Commit

Permalink
ENGCOM-1663: Include 'products' in category query #48
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Paliarush committed May 31, 2018
1 parent 2cb9aaf commit 18fe48c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ public function testCategoriesTree()
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Catalog/_files/categories_indexed.php
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testCategoryProducts()
{
$categoryId = 4;
$categoryId = 2;
$query = <<<QUERY
{
category(id: {$categoryId}) {
Expand Down Expand Up @@ -266,25 +265,21 @@ public function testCategoryProducts()
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('products', $response['category']);
$this->assertArrayHasKey('total_count', $response['category']['products']);
$this->assertEquals(2, $response['category']['products']['total_count']);
$this->assertGreaterThanOrEqual(1, $response['category']['products']['total_count']);
$this->assertEquals(1, $response['category']['products']['page_info']['current_page']);
$this->assertEquals(20, $response['category']['products']['page_info']['page_size']);

$this->assertArrayHasKey('sku', $response['category']['products']['items'][0]);
$firstProductSku = $response['category']['products']['items'][0]['sku'];

/**
* @var ProductRepositoryInterface $productRepository
*/
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
$firstProductSku = 'simple';
$firstProduct = $productRepository->get($firstProductSku, false, null, true);
$this->assertBaseFields($firstProduct, $response['category']['products']['items'][0]);
$this->assertAttributes($response['category']['products']['items'][0]);
$this->assertWebsites($firstProduct, $response['category']['products']['items'][0]['websites']);

$secondProductSku = '12345';
$secondProduct = $productRepository->get($secondProductSku, false, null, true);
$this->assertBaseFields($secondProduct, $response['category']['products']['items'][1]);
$this->assertAttributes($response['category']['products']['items'][1]);
$this->assertWebsites($secondProduct, $response['category']['products']['items'][1]['websites']);
}

/**
Expand All @@ -297,7 +292,6 @@ private function assertBaseFields($product, $actualResponse)
$assertionMap = [
['response_field' => 'attribute_set_id', 'expected_value' => $product->getAttributeSetId()],
['response_field' => 'created_at', 'expected_value' => $product->getCreatedAt()],
['response_field' => 'id', 'expected_value' => $product->getId()],
['response_field' => 'name', 'expected_value' => $product->getName()],
['response_field' => 'price', 'expected_value' =>
[
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 18fe48c

Please sign in to comment.