Skip to content

Commit a516457

Browse files
committed
Updated test changes for the CartCacheTest and ProductsCacheTest
1 parent 23120b9 commit a516457

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/Quote/Guest/CartCacheTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testCartIsNotCached()
3838
$this->assertArrayHasKey('cart', $responseMiss['body']);
3939
$this->assertArrayHasKey('items', $responseMiss['body']['cart']);
4040
$this->assertEquals('MISS', $responseMiss['headers']['X-Magento-Cache-Debug']);
41-
41+
4242
/** Cache debug header value is still a MISS for any subsequent request */
4343
$responseMissNext = $this->graphQlQueryWithResponseHeaders($getCartQuery);
4444
$this->assertEquals('MISS', $responseMissNext['headers']['X-Magento-Cache-Debug']);
@@ -105,7 +105,7 @@ private function addSimpleProductToCart($maskedCartId, $qty, $sku)
105105
}
106106

107107
/**
108-
* Get Check Cart query
108+
* Get cart query string
109109
*
110110
* @param string $maskedQuoteId
111111
* @return string

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
* @magentoAppArea graphql
1919
* @magentoCache full_page enabled
20+
* @magentoDbIsolation disabled
2021
*/
2122
class ProductsCacheTest extends AbstractGraphqlCacheTest
2223
{
@@ -39,6 +40,7 @@ protected function setUp(): void
3940
$this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
4041
$this->request = $this->objectManager->create(Http::class);
4142
}
43+
4244
/**
4345
* Test request is dispatched and response is checked for debug headers and cache tags
4446
*
@@ -83,4 +85,41 @@ public function testToCheckRequestCacheTagsForProducts(): void
8385
$expectedCacheTags = ['cat_p', 'cat_p_' . $product->getId(), 'FPC'];
8486
$this->assertEquals($expectedCacheTags, $actualCacheTags);
8587
}
88+
89+
/**
90+
* Test request is checked for debug headers and no cache tags for not existing product
91+
*/
92+
public function testToCheckRequestNoTagsForProducts(): void
93+
{
94+
$query
95+
= <<<QUERY
96+
{
97+
products(filter: {sku: {eq: "simple10"}})
98+
{
99+
items {
100+
id
101+
name
102+
sku
103+
description {
104+
html
105+
}
106+
}
107+
}
108+
}
109+
110+
QUERY;
111+
$this->request->setPathInfo('/graphql');
112+
$this->request->setMethod('GET');
113+
$this->request->setQueryValue('query', $query);
114+
/** @var \Magento\Framework\Controller\Result\Json $result */
115+
$result = $this->graphqlController->dispatch($this->request);
116+
/** @var \Magento\Framework\App\Response\Http $response */
117+
$response = $this->objectManager->get(\Magento\Framework\App\Response\Http::class);
118+
/** @var $registry \Magento\Framework\Registry */
119+
$result->renderResult($response);
120+
$this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue());
121+
$actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue());
122+
$expectedCacheTags = [ 'FPC'];
123+
$this->assertEquals($expectedCacheTags, $actualCacheTags);
124+
}
86125
}

0 commit comments

Comments
 (0)