-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OXDEV-7768 Remove Template cache service
- Loading branch information
1 parent
1b8b682
commit 045eb0b
Showing
15 changed files
with
119 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
source/Internal/Framework/Templating/Cache/TemplateCacheService.php
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
source/Internal/Framework/Templating/Cache/TemplateCacheServiceInterface.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
tests/Integration/Internal/Framework/Templating/Cache/MultiShopTemplateCacheServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\EshopCommunity\Tests\Integration\Internal\Framework\Templating\Cache; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface; | ||
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; | ||
use OxidEsales\EshopCommunity\Tests\ContainerTrait; | ||
use OxidEsales\EshopCommunity\Tests\TestContainerFactory; | ||
use OxidEsales\EshopCommunity\Tests\Unit\Internal\ContextStub; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Filesystem\Path; | ||
|
||
final class MultiShopTemplateCacheServiceTest extends TestCase | ||
{ | ||
use ContainerTrait; | ||
|
||
private string $testFixturesDirectory = __DIR__ . '/cache_fixtures'; | ||
private int $shopId1 = 123; | ||
private int $shopId2 = 456; | ||
private array $allShopIds = []; | ||
private array $cacheFixturesForShopId = []; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->allShopIds = [ | ||
$this->shopId1, | ||
$this->shopId2, | ||
]; | ||
$this->stubContext(); | ||
$this->generateCacheFixtures(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->cleanupCache(); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function testInvalidateCacheWillKeepOtherShopsCacheFile(): void | ||
{ | ||
$this->get(ShopTemplateCacheServiceInterface::class)->invalidateCache($this->shopId1); | ||
|
||
$this->assertFileDoesNotExist($this->cacheFixturesForShopId[$this->shopId1]); | ||
$this->assertFileExists($this->cacheFixturesForShopId[$this->shopId2]); | ||
} | ||
|
||
public function testInvalidateAllShopsCacheWillRemoveAllCacheFiles(): void | ||
{ | ||
$this->get(ShopTemplateCacheServiceInterface::class)->invalidateAllShopsCache(); | ||
|
||
$this->assertFileDoesNotExist($this->cacheFixturesForShopId[$this->shopId1]); | ||
$this->assertFileDoesNotExist($this->cacheFixturesForShopId[$this->shopId2]); | ||
} | ||
|
||
private function stubContext(): void | ||
{ | ||
$context = new ContextStub(); | ||
$context->setCacheDirectory($this->testFixturesDirectory); | ||
$context->setAllShopIds($this->allShopIds); | ||
|
||
$this->container = (new TestContainerFactory())->create(); | ||
$this->container->set(ContextInterface::class, $context); | ||
$this->container->autowire(ContextInterface::class, ContextInterface::class); | ||
$this->container->compile(); | ||
} | ||
|
||
private function generateCacheFixtures(): void | ||
{ | ||
$filesystem = $this->get('oxid_esales.symfony.file_system'); | ||
|
||
foreach ($this->allShopIds as $shopId) { | ||
$templateCacheDirectory = $this->get(ShopTemplateCacheServiceInterface::class)->getCacheDirectory($shopId); | ||
$filesystem->mkdir($templateCacheDirectory); | ||
$this->cacheFixturesForShopId[$shopId] = Path::join($templateCacheDirectory, 'some-cache-file'); | ||
$filesystem->touch($this->cacheFixturesForShopId[$shopId]); | ||
} | ||
|
||
$this->assertFileExists($this->cacheFixturesForShopId[$this->shopId1]); | ||
$this->assertFileExists($this->cacheFixturesForShopId[$this->shopId2]); | ||
} | ||
|
||
private function cleanupCache(): void | ||
{ | ||
$this->get('oxid_esales.symfony.file_system')->remove($this->testFixturesDirectory); | ||
} | ||
} |
103 changes: 0 additions & 103 deletions
103
tests/Integration/Internal/Framework/Templating/Cache/ShopTemplateCacheServiceTest.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.