Skip to content

Commit 87fed9a

Browse files
author
Prabhu Ram
committed
Merge remote-tracking branch 'marjan/category-list-tags-29372' into 2.4-develop
2 parents 51b53be + 9fab8bc commit 87fed9a

File tree

3 files changed

+107
-145
lines changed

3 files changed

+107
-145
lines changed

dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryListCacheTest.php

Lines changed: 0 additions & 145 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQlCache\Controller\Catalog;
9+
10+
use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest;
11+
12+
/**
13+
* Test caching for categoryList query
14+
*
15+
* @magentoAppArea graphql
16+
* @magentoCache full_page enabled
17+
* @magentoDbIsolation disabled
18+
*/
19+
class CategoryListMultipleIdsCacheTest extends AbstractGraphqlCacheTest
20+
{
21+
/**
22+
* Test request is served from cache. Expected cache tags are equal in both MISS and HIT cases.
23+
*
24+
* @magentoDataFixture Magento/Catalog/_files/category_tree.php
25+
*/
26+
public function testSecondRequestIsServedFromCacheOnMultipleIds()
27+
{
28+
$categoryId1 ='400';
29+
$categoryId2 = '401';
30+
$query
31+
= <<<QUERY
32+
{
33+
categoryList(filters: {ids: {in: ["$categoryId1", "$categoryId2"]}}) {
34+
id
35+
name
36+
url_key
37+
description
38+
product_count
39+
}
40+
}
41+
QUERY;
42+
$expectedCacheTags = ['cat_c', 'cat_c_' . $categoryId1, 'cat_c_' . $categoryId2, 'FPC'];
43+
44+
$response = $this->dispatchGraphQlGETRequest(['query' => $query]);
45+
$this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue());
46+
$actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue());
47+
$this->assertEquals($expectedCacheTags, $actualCacheTags);
48+
49+
$cacheResponse = $this->dispatchGraphQlGETRequest(['query' => $query]);
50+
$this->assertEquals('HIT', $cacheResponse->getHeader('X-Magento-Cache-Debug')->getFieldValue());
51+
$actualCacheTags = explode(',', $cacheResponse->getHeader('X-Magento-Tags')->getFieldValue());
52+
$this->assertEquals($expectedCacheTags, $actualCacheTags);
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQlCache\Controller\Catalog;
9+
10+
use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest;
11+
12+
/**
13+
* Test caching for categoryList query
14+
*
15+
* @magentoAppArea graphql
16+
* @magentoCache full_page enabled
17+
* @magentoDbIsolation disabled
18+
*/
19+
class CategoryListSingleIdCacheTest extends AbstractGraphqlCacheTest
20+
{
21+
/**
22+
* Test request is served from cache. Expected cache tags are equal in both MISS and HIT cases.
23+
*
24+
* @magentoDataFixture Magento/Catalog/_files/category_product.php
25+
*/
26+
public function testSecondRequestIsServedFromCache()
27+
{
28+
$categoryId ='333';
29+
$query
30+
= <<<QUERY
31+
{
32+
categoryList(filters: {ids: {in: ["$categoryId"]}}) {
33+
id
34+
name
35+
url_key
36+
description
37+
product_count
38+
}
39+
}
40+
QUERY;
41+
$expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC'];
42+
43+
$response = $this->dispatchGraphQlGETRequest(['query' => $query]);
44+
$this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue());
45+
$actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue());
46+
$this->assertEquals($expectedCacheTags, $actualCacheTags);
47+
48+
$cacheResponse = $this->dispatchGraphQlGETRequest(['query' => $query]);
49+
$this->assertEquals('HIT', $cacheResponse->getHeader('X-Magento-Cache-Debug')->getFieldValue());
50+
$actualCacheTags = explode(',', $cacheResponse->getHeader('X-Magento-Tags')->getFieldValue());
51+
$this->assertEquals($expectedCacheTags, $actualCacheTags);
52+
}
53+
}

0 commit comments

Comments
 (0)