Skip to content

Commit 8b0fd03

Browse files
committed
Merge branch 'B2B-2471' into B2B-2459
2 parents c9d1622 + 30d2ad6 commit 8b0fd03

File tree

5 files changed

+612
-53
lines changed

5 files changed

+612
-53
lines changed

app/code/Magento/CatalogUrlRewriteGraphQl/Model/Resolver/UrlRewrite/CatalogUrlResolverIdentity.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ class CatalogUrlResolverIdentity implements IdentityInterface
2929
public function getIdentities(array $resolvedData): array
3030
{
3131
$ids = [];
32-
if (isset($resolvedData['id'])) {
32+
$entity_id = $resolvedData['id'] ?? $resolvedData['entity_id'] ?? null;
33+
if (isset($entity_id)) {
3334
$selectedCacheTag = isset($resolvedData['type']) ?
3435
$this->getTagFromEntityType($resolvedData['type']) : '';
3536
if (!empty($selectedCacheTag)) {
36-
$ids = [$selectedCacheTag, sprintf('%s_%s', $selectedCacheTag, $resolvedData['id'])];
37+
$ids = [$selectedCacheTag, sprintf('%s_%s', $selectedCacheTag, $entity_id)];
3738
}
3839
}
3940
return $ids;

app/code/Magento/CmsUrlRewriteGraphQl/Model/Resolver/UrlRewrite/CmsUrlResolverIdentity.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class CmsUrlResolverIdentity implements IdentityInterface
2626
public function getIdentities(array $resolvedData): array
2727
{
2828
$ids = [];
29-
if (isset($resolvedData['id'])) {
29+
$id = $resolvedData['id'] ?? $resolvedData['page_id'] ?? null;
30+
if (isset($id)) {
3031
$selectedCacheTag = $this->cacheTag;
31-
$ids = [$selectedCacheTag, sprintf('%s_%s', $selectedCacheTag, $resolvedData['id'])];
32+
$ids = [$selectedCacheTag, sprintf('%s_%s', $selectedCacheTag, $id)];
3233
}
3334
return $ids;
3435
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\GraphQl\PageCache;
9+
10+
use Magento\TestFramework\TestCase\GraphQlAbstract;
11+
12+
/**
13+
* Abstract class for GraphQL page cache test
14+
*/
15+
class GraphQLPageCacheAbstract extends GraphQlAbstract
16+
{
17+
/**
18+
* Assert that we obtain a cache MISS when sending the provided query & headers.
19+
*
20+
* @param string $query
21+
* @param array $headers
22+
* @return array
23+
*/
24+
protected function assertCacheMissAndReturnResponse(string $query, array $headers) :array
25+
{
26+
$responseMiss = $this->graphQlQueryWithResponseHeaders($query, [], '', $headers);
27+
$this->assertArrayHasKey('X-Magento-Cache-Debug', $responseMiss['headers']);
28+
$this->assertEquals('MISS', $responseMiss['headers']['X-Magento-Cache-Debug']);
29+
return $responseMiss;
30+
}
31+
32+
/**
33+
* Assert that we obtain a cache HIT when sending the provided query & headers.
34+
*
35+
* @param string $query
36+
* @param array $headers
37+
* @return array
38+
*/
39+
protected function assertCacheHitAndReturnResponse(string $query, array $headers) :array
40+
{
41+
$responseHit = $this->graphQlQueryWithResponseHeaders($query, [], '', $headers);
42+
$this->assertArrayHasKey('X-Magento-Cache-Debug', $responseHit['headers']);
43+
$this->assertEquals('HIT', $responseHit['headers']['X-Magento-Cache-Debug']);
44+
return $responseHit;
45+
}
46+
}

0 commit comments

Comments
 (0)