Skip to content

Commit 124ad9d

Browse files
committed
Merge branch 'graphql-issue-230' of github.com:magento-honey-badgers/magento2ce into graphql-issue-230
2 parents 7ab4ddd + f91c560 commit 124ad9d

File tree

1 file changed

+19
-48
lines changed

1 file changed

+19
-48
lines changed

dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/CmsPageCacheTest.php

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,43 @@
99

1010
use Magento\Cms\Model\GetPageByIdentifier;
1111
use Magento\Framework\App\Request\Http;
12-
use Magento\Framework\EntityManager\MetadataPool;
13-
use Magento\Framework\Serialize\SerializerInterface;
14-
use Magento\TestFramework\Helper\Bootstrap;
1512
use Magento\GraphQl\Controller\GraphQl;
13+
use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest;
1614

1715
/**
1816
* Test caching works for CMS page
1917
*
2018
* @magentoAppArea graphql
21-
* @magentoDbIsolation disabled
19+
* @magentoCache full_page enabled
2220
*/
23-
class CmsPageCacheTest extends \Magento\TestFramework\Indexer\TestCase
21+
class CmsPageCacheTest extends AbstractGraphqlCacheTest
2422
{
25-
const CONTENT_TYPE = 'application/json';
26-
27-
/** @var \Magento\Framework\ObjectManagerInterface */
28-
private $objectManager;
29-
30-
/** @var GraphQl */
31-
private $graphql;
32-
33-
/** @var SerializerInterface */
34-
private $jsonSerializer;
35-
36-
/** @var MetadataPool */
37-
private $metadataPool;
38-
39-
/** @var Http */
40-
private $request;
41-
4223
/**
43-
* @inheritdoc
24+
* @var GraphQl
4425
*/
45-
public static function setUpBeforeClass()
46-
{
47-
$db = Bootstrap::getInstance()->getBootstrap()
48-
->getApplication()
49-
->getDbInstance();
50-
if (!$db->isDbDumpExists()) {
51-
throw new \LogicException('DB dump does not exist.');
52-
}
53-
$db->restoreFromDbDump();
26+
private $graphqlController;
5427

55-
parent::setUpBeforeClass();
56-
}
28+
/**
29+
* @var Http
30+
*/
31+
private $request;
5732

5833
/**
5934
* @inheritdoc
6035
*/
6136
protected function setUp(): void
6237
{
63-
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
64-
$this->graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
65-
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
66-
$this->metadataPool = $this->objectManager->get(MetadataPool::class);
67-
$this->request = $this->objectManager->get(Http::class);
38+
parent::setUp();
39+
$this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
40+
$this->request = $this->objectManager->create(Http::class);
6841
}
42+
6943
/**
70-
* Test cache tags and debug header for category and querying only cms page
44+
* Test that the correct cache tags get added to request for cmsPage query
7145
*
72-
* @magentoCache all enabled
7346
* @magentoDataFixture Magento/Cms/_files/pages.php
7447
*/
75-
public function testDispatchWithGetForCacheDebugHeadersAndCacheTagsForCmsPage(): void
48+
public function testToCheckCmsPageRequestCacheTags(): void
7649
{
7750
$cmsPage = $this->objectManager->get(GetPageByIdentifier::class)->execute('page100', 0);
7851
$pageId = $cmsPage->getId();
@@ -92,20 +65,18 @@ public function testDispatchWithGetForCacheDebugHeadersAndCacheTagsForCmsPage():
9265
}
9366
}
9467
QUERY;
68+
9569
$this->request->setPathInfo('/graphql');
9670
$this->request->setMethod('GET');
9771
$this->request->setQueryValue('query', $query);
9872
/** @var \Magento\Framework\Controller\Result\Json $result */
99-
$result = $this->graphql->dispatch($this->request);
73+
$result = $this->graphqlController->dispatch($this->request);
10074
/** @var \Magento\Framework\App\Response\Http $response */
10175
$response = $this->objectManager->get(\Magento\Framework\App\Response\Http::class);
102-
/** @var $registry \Magento\Framework\Registry */
103-
$registry = $this->objectManager->get(\Magento\Framework\Registry::class);
104-
$registry->register('use_page_cache_plugin', true, true);
10576
$result->renderResult($response);
10677
$this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue());
107-
$actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue());
78+
$requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue());
10879
$expectedCacheTags = ['cms_p', 'cms_p_' .$pageId , 'FPC'];
109-
$this->assertEquals($expectedCacheTags, $actualCacheTags);
80+
$this->assertEquals($expectedCacheTags, $requestedCacheTags);
11081
}
11182
}

0 commit comments

Comments
 (0)