diff --git a/bundle/Cache/PersistenceCachePurger.php b/bundle/Cache/PersistenceCachePurger.php index e965d63c..4471a586 100644 --- a/bundle/Cache/PersistenceCachePurger.php +++ b/bundle/Cache/PersistenceCachePurger.php @@ -13,7 +13,6 @@ use eZ\Publish\API\Repository\Exceptions\NotFoundException as APINotFoundException; use eZ\Publish\SPI\Persistence\Content\Location\Handler as LocationHandlerInterface; use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType; -use Psr\Log\LoggerInterface; /** * Class PersistenceCachePurger. @@ -39,23 +38,16 @@ class PersistenceCachePurger implements CacheClearerInterface */ protected $allCleared = false; - /** - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - /** * Setups current handler with everything needed. * * @param \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface $cache * @param \eZ\Publish\SPI\Persistence\Content\Location\Handler $locationHandler (using SPI cache instance so calls are cached) - * @param \Psr\Log\LoggerInterface $logger */ - public function __construct(TagAwareAdapterInterface $cache, LocationHandlerInterface $locationHandler, LoggerInterface $logger) + public function __construct(TagAwareAdapterInterface $cache, LocationHandlerInterface $locationHandler) { $this->cache = $cache; $this->locationHandler = $locationHandler; - $this->logger = $logger; } /** diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index ef8dbe6c..8802e304 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -243,7 +243,6 @@ services: arguments: - "@ezpublish.cache_pool" - "@ezpublish.spi.persistence.cache.locationHandler" - - "@logger" tags: - { name: kernel.cache_clearer } lazy: true diff --git a/bundle/Tests/Cache/PersistenceCachePurgerTest.php b/bundle/Tests/Cache/PersistenceCachePurgerTest.php index 09c49642..859d1590 100644 --- a/bundle/Tests/Cache/PersistenceCachePurgerTest.php +++ b/bundle/Tests/Cache/PersistenceCachePurgerTest.php @@ -14,7 +14,6 @@ use eZ\Publish\Core\Base\Exceptions\NotFoundException; use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; class PersistenceCachePurgerTest extends TestCase { @@ -33,20 +32,15 @@ class PersistenceCachePurgerTest extends TestCase */ private $cachePurger; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $logger; - protected function setUp() { parent::setUp(); $this->cacheService = $this->createMock(TagAwareAdapterInterface::class); $this->locationHandler = $this->createMock(Handler::class); - $this->logger = $this->createMock(LoggerInterface::class); $this->cachePurger = new PersistenceCachePurger( - $this->cacheService, $this->locationHandler, $this->logger + $this->cacheService, + $this->locationHandler ); } @@ -61,10 +55,6 @@ public function testNotFoundLocation() ->method('load') ->will($this->throwException(new NotFoundException('location', $id))); - $this->logger - ->expects($this->once()) - ->method('notice'); - $this->cachePurger->content($id); } @@ -140,15 +130,10 @@ public function testClearAllDisabled() */ public function testClearAllContent() { - $map = array( - array('content', null), - array('urlAlias', null), - array('location', null), - ); $this->cacheService - ->expects($this->exactly(count($map))) - ->method('clear') - ->will($this->returnValueMap($map)); + ->expects($this->once()) + ->method('clear'); + $this->assertNull($this->cachePurger->content()); } @@ -261,8 +246,8 @@ public function testClearContentTypeAll() { $this->cacheService ->expects($this->once()) - ->method('clear') - ->with('contentType'); + ->method('invalidateTags') + ->with(['type-map']); $this->cachePurger->contentType(); } @@ -274,8 +259,8 @@ public function testClearContentType() { $this->cacheService ->expects($this->once()) - ->method('clear') - ->with('contentType', 123); + ->method('invalidateTags') + ->with(['type-123']); $this->cachePurger->contentType(123); } @@ -290,42 +275,15 @@ public function testClearContentTypeFail() $this->cachePurger->contentType(new \stdClass()); } - /** - * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::contentTypeGroup - */ - public function testClearContentTypeGroupAll() - { - $this->cacheService - ->expects($this->exactly(2)) - ->method('clear') - ->will( - $this->returnValueMap( - array( - array('contentTypeGroup', null), - array('contentType', null), - ) - ) - ); - - $this->cachePurger->contentTypeGroup(); - } - /** * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::contentTypeGroup */ public function testClearContentTypeGroup() { $this->cacheService - ->expects($this->exactly(2)) - ->method('clear') - ->will( - $this->returnValueMap( - array( - array('contentTypeGroup', 123, null), - array('contentType', null), - ) - ) - ); + ->expects($this->once()) + ->method('invalidateTags') + ->with(['type-group-123', 'type-map']); $this->cachePurger->contentTypeGroup(123); } @@ -340,19 +298,6 @@ public function testClearContentTypeGroupFail() $this->cachePurger->contentTypeGroup(new \stdClass()); } - /** - * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::section - */ - public function testClearSectionAll() - { - $this->cacheService - ->expects($this->once()) - ->method('clear') - ->with('section'); - - $this->cachePurger->section(); - } - /** * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::section */ @@ -360,8 +305,8 @@ public function testClearSection() { $this->cacheService ->expects($this->once()) - ->method('clear') - ->with('section', 123); + ->method('invalidateTags') + ->with(['section-123']); $this->cachePurger->section(123); } @@ -386,17 +331,9 @@ public function testClearLanguages() $languageId3 = 789; $this->cacheService - ->expects($this->exactly(3)) - ->method('clear') - ->will( - $this->returnValueMap( - array( - array($languageId1, null), - array($languageId2, null), - array($languageId3, null), - ) - ) - ); + ->expects($this->once()) + ->method('invalidateTags') + ->with(['language-123', 'language-456', 'language-789']); $this->cachePurger->languages(array($languageId1, $languageId2, $languageId3)); } @@ -410,14 +347,8 @@ public function testClearOneLanguage() $this->cacheService ->expects($this->once()) - ->method('clear') - ->will( - $this->returnValueMap( - array( - array($languageId, null), - ) - ) - ); + ->method('invalidateTags') + ->with(['language-123']); $this->cachePurger->languages($languageId); }