Skip to content

Commit 515fc93

Browse files
committed
AC-13719: Cache Keys associated with FPC on Magento 2.4.7 multi-store implementations
teardown for reverting the cache state after the test
1 parent 1960b3f commit 515fc93

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

dev/tests/integration/testsuite/Magento/PageCache/Model/App/CacheIdentifierPluginTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\PageCache\Model\App;
99

10+
use Magento\Framework\App\Cache\StateInterface;
1011
use Magento\Framework\App\PageCache\Identifier;
1112
use Magento\Framework\App\Request\Http;
1213
use Magento\Framework\ObjectManagerInterface;
@@ -48,16 +49,37 @@ class CacheIdentifierPluginTest extends TestCase
4849
*/
4950
private $fixtures;
5051

52+
/**
53+
* @var StateInterface
54+
*/
55+
private $cacheState;
56+
57+
/**
58+
* @var bool
59+
*/
60+
private $originalCacheState;
61+
5162
protected function setUp(): void
5263
{
5364
$this->objectManager = Bootstrap::getObjectManager();
5465
$this->request = $this->objectManager->get(Http::class);
5566
$this->identifier = $this->objectManager->get(Identifier::class);
5667
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
68+
$this->cacheState = $this->objectManager->get(StateInterface::class);
69+
70+
// Store original cache state
71+
$this->originalCacheState = $this->cacheState->isEnabled(Type::TYPE_IDENTIFIER);
5772

5873
// Enable the cache type
59-
$this->objectManager->get(\Magento\Framework\App\Cache\StateInterface::class)
60-
->setEnabled(Type::TYPE_IDENTIFIER, true);
74+
$this->cacheState->setEnabled(Type::TYPE_IDENTIFIER, true);
75+
}
76+
77+
protected function tearDown(): void
78+
{
79+
// Revert cache state to original
80+
if (isset($this->cacheState) && isset($this->originalCacheState)) {
81+
$this->cacheState->setEnabled(Type::TYPE_IDENTIFIER, $this->originalCacheState);
82+
}
6183
}
6284

6385
/**

0 commit comments

Comments
 (0)