17
17
*
18
18
* @magentoAppArea graphql
19
19
* @magentoCache full_page enabled
20
+ * @magentoDbIsolation disabled
20
21
*/
21
22
class ProductsCacheTest extends AbstractGraphqlCacheTest
22
23
{
@@ -39,6 +40,7 @@ protected function setUp(): void
39
40
$ this ->graphqlController = $ this ->objectManager ->get (\Magento \GraphQl \Controller \GraphQl::class);
40
41
$ this ->request = $ this ->objectManager ->create (Http::class);
41
42
}
43
+
42
44
/**
43
45
* Test request is dispatched and response is checked for debug headers and cache tags
44
46
*
@@ -83,4 +85,41 @@ public function testToCheckRequestCacheTagsForProducts(): void
83
85
$ expectedCacheTags = ['cat_p ' , 'cat_p_ ' . $ product ->getId (), 'FPC ' ];
84
86
$ this ->assertEquals ($ expectedCacheTags , $ actualCacheTags );
85
87
}
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
+ }
86
125
}
0 commit comments