From e04b7fbfae8b945a879b96479aae5720d67b2b80 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Mon, 25 Nov 2024 12:47:02 +0100 Subject: [PATCH] Applying CR suggestions --- .../Cache/Tests/ContentHandlerTest.php | 21 ++++++++++--------- .../Core/Persistence/Cache/TrashHandler.php | 7 ++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php b/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php index 4c0deae62e..2bfa20bd32 100644 --- a/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php +++ b/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php @@ -49,7 +49,7 @@ public function providerForUnCachedMethods(): array ['setStatus', [2, 0, 1], [['content_version', [2, 1], false]], null, ['c-2-v-1']], ['setStatus', [2, 1, 1], [['content', [2], false]], null, ['c-2']], ['updateMetadata', [2, new MetadataUpdateStruct()], [['content', [2], false]], null, ['c-2']], - //['updateContent', [2, 1, new UpdateStruct()], [['content_version', [2, 1], false]], null, ['c-2-v-1']], + ['updateContent', [2, 1, new UpdateStruct()], [['content_version', [2, 1], false]], null, ['c-2-v-1']], //['deleteContent', [2]], own tests for relations complexity ['deleteVersion', [2, 1], [['content_version', [2, 1], false]], null, ['c-2-v-1']], ['addRelation', [new RelationCreateStruct()]], @@ -308,7 +308,7 @@ public function providerForCachedLoadMethodsMiss(): array /** * @covers \eZ\Publish\Core\Persistence\Cache\ContentHandler::updateContent */ - public function testUpdateContent() + public function testUpdateContent(): void { $this->loggerMock->expects($this->once())->method('logCall'); @@ -332,14 +332,15 @@ public function testUpdateContent() $this->cacheIdentifierGeneratorMock ->expects($this->exactly(5)) ->method('generateTag') - ->withConsecutive( - ['location', [3], false], - ['location', [4], false], - ['location_path', [3], false], - ['location_path', [4], false], - ['content_version', [2, 1], false], - ) - ->willReturnOnConsecutiveCalls('l-3', 'l-4', 'lp-3', 'lp-4', 'c-2-v-1'); + ->will( + self::returnValueMap([ + ['location', [3], false, 'l-3'], + ['location', [4], false, 'l-4'], + ['location_path', [3], false, 'lp-3'], + ['location_path', [4], false, 'lp-4'], + ['content_version', [2, 1], false, 'c-2-v-1'], + ]) + ); $this->cacheMock ->expects($this->once()) diff --git a/eZ/Publish/Core/Persistence/Cache/TrashHandler.php b/eZ/Publish/Core/Persistence/Cache/TrashHandler.php index a5e03abf2b..bbb8ece068 100644 --- a/eZ/Publish/Core/Persistence/Cache/TrashHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/TrashHandler.php @@ -41,8 +41,9 @@ public function trashSubtree($locationId) $location = $this->persistenceHandler->locationHandler()->load($locationId); $contentId = $location->contentId; - $reverseRelations = $this->persistenceHandler->contentHandler()->loadRelations($contentId); - $versions = $this->persistenceHandler->contentHandler()->listVersions($contentId); + $contentHandler = $this->persistenceHandler->contentHandler(); + $reverseRelations = $contentHandler->loadRelations($contentId); + $versions = $contentHandler->listVersions($contentId); $return = $this->persistenceHandler->trashHandler()->trashSubtree($locationId); $relationTags = []; @@ -56,7 +57,7 @@ public function trashSubtree($locationId) } $versionTags = array_map(function (VersionInfo $versionInfo) use ($contentId): string { - return $this->cacheIdentifierGenerator->generateTag( + return $this->cacheIdentifierGenerator->generateTag( self::CONTENT_VERSION_IDENTIFIER, [$contentId, $versionInfo->versionNo] );