10
10
use Magento \Cms \Model \BlockRepository ;
11
11
use Magento \Framework \App \Request \Http ;
12
12
use Magento \GraphQl \Controller \GraphQl ;
13
- use Magento \TestFramework \ObjectManager ;
14
- use Magento \TestFramework \Helper \Bootstrap ;
13
+ use Magento \GraphQlCache \Controller \AbstractGraphqlCacheTest ;
15
14
16
15
/**
17
16
* Test caching works for CMS blocks
18
17
*
19
18
* @magentoAppArea graphql
20
- * @magentoDbIsolation disabled
19
+ * @magentoCache full_page enabled
21
20
*/
22
- class BlockCacheTest extends \ Magento \ TestFramework \ Indexer \TestCase
21
+ class BlockCacheTest extends AbstractGraphqlCacheTest
23
22
{
24
- /**
25
- * @var ObjectManager
26
- */
27
- private $ objectManager ;
28
-
29
23
/**
30
24
* @var GraphQl
31
25
*/
@@ -36,31 +30,14 @@ class BlockCacheTest extends \Magento\TestFramework\Indexer\TestCase
36
30
*/
37
31
private $ request ;
38
32
39
- /**
40
- * @inheritdoc
41
- */
42
- public static function setUpBeforeClass ()
43
- {
44
- $ db = Bootstrap::getInstance ()->getBootstrap ()
45
- ->getApplication ()
46
- ->getDbInstance ();
47
- if (!$ db ->isDbDumpExists ()) {
48
- throw new \LogicException ('DB dump does not exist. ' );
49
- }
50
- $ db ->restoreFromDbDump ();
51
-
52
- parent ::setUpBeforeClass ();
53
- }
54
-
55
33
/**
56
34
* @inheritdoc
57
35
*/
58
36
protected function setUp (): void
59
37
{
60
- $ this -> objectManager = Bootstrap:: getObjectManager ();
38
+ parent :: setUp ();
61
39
$ this ->graphqlController = $ this ->objectManager ->get (\Magento \GraphQl \Controller \GraphQl::class);
62
40
$ this ->request = $ this ->objectManager ->create (Http::class);
63
- $ this ->enableFullPageCache ();
64
41
}
65
42
66
43
/**
@@ -103,18 +80,4 @@ public function testCmsBlocksRequestHasCorrectTags(): void
103
80
$ this ->assertContains ($ expectedCacheTag , $ actualCacheTags );
104
81
}
105
82
}
106
-
107
- /**
108
- * Enable full page cache so plugins are called
109
- */
110
- private function enableFullPageCache ()
111
- {
112
- /** @var $registry \Magento\Framework\Registry */
113
- $ registry = $ this ->objectManager ->get (\Magento \Framework \Registry::class);
114
- $ registry ->register ('use_page_cache_plugin ' , true , true );
115
-
116
- /** @var \Magento\Framework\App\Cache\StateInterface $cacheState */
117
- $ cacheState = $ this ->objectManager ->get (\Magento \Framework \App \Cache \StateInterface::class);
118
- $ cacheState ->setEnabled (\Magento \PageCache \Model \Cache \Type::TYPE_IDENTIFIER , true );
119
- }
120
83
}
0 commit comments