Skip to content

Commit 7196788

Browse files
Changes after CR#1
1 parent ed32613 commit 7196788

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

src/lib/Persistence/Cache/ContentHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
78
namespace Ibexa\Core\Persistence\Cache;
89

910
use Ibexa\Contracts\Core\Persistence\Content;
@@ -329,9 +330,10 @@ public function updateMetadata($contentId, MetadataUpdateStruct $struct)
329330
}
330331

331332
/**
332-
* {@inheritdoc}
333+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
334+
* @throws \Psr\Cache\InvalidArgumentException
333335
*/
334-
public function updateContent($contentId, $versionNo, UpdateStruct $struct)
336+
public function updateContent($contentId, $versionNo, UpdateStruct $struct): Content
335337
{
336338
$this->logger->logCall(__METHOD__, ['content' => $contentId, 'version' => $versionNo, 'struct' => $struct]);
337339
$content = $this->persistenceHandler->contentHandler()->updateContent($contentId, $versionNo, $struct);

tests/lib/Persistence/Cache/ContentHandlerTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Ibexa\Contracts\Core\Persistence\Content\ContentInfo;
1111
use Ibexa\Contracts\Core\Persistence\Content\CreateStruct;
1212
use Ibexa\Contracts\Core\Persistence\Content\Handler as SPIContentHandler;
13-
use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as SPILocationHandler;
13+
use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as PersistenceLocationHandler;
1414
use Ibexa\Contracts\Core\Persistence\Content\MetadataUpdateStruct;
1515
use Ibexa\Contracts\Core\Persistence\Content\Relation;
1616
use Ibexa\Contracts\Core\Persistence\Content\Relation as SPIRelation;
@@ -444,7 +444,7 @@ public function testUpdateContent(): void
444444
$this->loggerMock->expects($this->once())->method('logCall');
445445

446446
$innerContentHandlerMock = $this->createMock(SPIContentHandler::class);
447-
$innerLocationHandlerMock = $this->createMock(SPILocationHandler::class);
447+
$innerLocationHandlerMock = $this->createMock(PersistenceLocationHandler::class);
448448

449449
$this->prepareHandlerMocks(
450450
$innerContentHandlerMock,
@@ -455,39 +455,39 @@ public function testUpdateContent(): void
455455
);
456456

457457
$innerContentHandlerMock
458-
->expects($this->once())
458+
->expects(self::once())
459459
->method('updateContent')
460460
->with(2, 1, new UpdateStruct())
461461
->willReturn(new Content());
462462

463463
$this->cacheIdentifierGeneratorMock
464-
->expects($this->exactly(5))
464+
->expects(self::exactly(5))
465465
->method('generateTag')
466-
->will(
467-
self::returnValueMap([
466+
->willReturnMap(
467+
[
468468
['location', [3], false, 'l-3'],
469469
['location', [4], false, 'l-4'],
470470
['location_path', [3], false, 'lp-3'],
471471
['location_path', [4], false, 'lp-4'],
472472
['content_version', [2, 1], false, 'c-2-v-1'],
473-
])
473+
]
474474
);
475475

476476
$this->cacheMock
477-
->expects($this->once())
477+
->expects(self::once())
478478
->method('invalidateTags')
479479
->with(['l-3', 'l-4', 'lp-3', 'lp-4', 'c-2-v-1']);
480480

481481
$handler = $this->persistenceCacheHandler->contentHandler();
482482
$handler->updateContent(2, 1, new UpdateStruct());
483483
}
484484

485-
public function testDeleteContent()
485+
public function testDeleteContent(): void
486486
{
487-
$this->loggerMock->expects($this->once())->method('logCall');
487+
$this->loggerMock->expects(self::once())->method('logCall');
488488

489489
$innerContentHandlerMock = $this->createMock(SPIContentHandler::class);
490-
$innerLocationHandlerMock = $this->createMock(SPILocationHandler::class);
490+
$innerLocationHandlerMock = $this->createMock(PersistenceLocationHandler::class);
491491

492492
$this->prepareHandlerMocks(
493493
$innerContentHandlerMock,
@@ -496,17 +496,17 @@ public function testDeleteContent()
496496
);
497497

498498
$innerContentHandlerMock
499-
->expects($this->once())
499+
->expects(self::once())
500500
->method('deleteContent')
501501
->with(2)
502502
->willReturn(true);
503503

504504
$this->cacheMock
505-
->expects($this->never())
505+
->expects(self::never())
506506
->method('deleteItem');
507507

508508
$this->cacheIdentifierGeneratorMock
509-
->expects($this->exactly(4))
509+
->expects(self::exactly(4))
510510
->method('generateTag')
511511
->withConsecutive(
512512
['content', [42], false],
@@ -517,7 +517,7 @@ public function testDeleteContent()
517517
->willReturnOnConsecutiveCalls('c-42', 'c-2', 'l-3', 'l-4');
518518

519519
$this->cacheMock
520-
->expects($this->once())
520+
->expects(self::once())
521521
->method('invalidateTags')
522522
->with(['c-42', 'c-2', 'l-3', 'l-4']);
523523

@@ -531,19 +531,19 @@ public function testDeleteContent()
531531
*/
532532
private function prepareHandlerMocks(
533533
SPIContentHandler $innerContentHandlerMock,
534-
SPILocationHandler $innerLocationHandlerMock,
534+
PersistenceLocationHandler $innerLocationHandlerMock,
535535
int $contentHandlerCount = 1,
536536
int $locationHandlerCount = 1,
537537
int $loadReverseRelationsCount = 1,
538538
int $loadLocationsByContentCount = 1
539539
): void {
540540
$this->persistenceHandlerMock
541-
->expects($this->exactly($contentHandlerCount))
541+
->expects(self::exactly($contentHandlerCount))
542542
->method('contentHandler')
543543
->willReturn($innerContentHandlerMock);
544544

545545
$innerContentHandlerMock
546-
->expects($this->exactly($loadReverseRelationsCount))
546+
->expects(self::exactly($loadReverseRelationsCount))
547547
->method('loadReverseRelations')
548548
->with(2, APIRelation::FIELD | APIRelation::ASSET)
549549
->willReturn(
@@ -553,12 +553,12 @@ private function prepareHandlerMocks(
553553
);
554554

555555
$this->persistenceHandlerMock
556-
->expects($this->exactly($locationHandlerCount))
556+
->expects(self::exactly($locationHandlerCount))
557557
->method('locationHandler')
558558
->willReturn($innerLocationHandlerMock);
559559

560560
$innerLocationHandlerMock
561-
->expects($this->exactly($loadLocationsByContentCount))
561+
->expects(self::exactly($loadLocationsByContentCount))
562562
->method('loadLocationsByContent')
563563
->with(2)
564564
->willReturn(

tests/lib/Persistence/Cache/TrashHandlerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ public function testTrashSubtree()
149149
->willReturn($locationHandlerMock);
150150

151151
$this->persistenceHandlerMock
152-
->expects($this->once())
152+
->expects(self::once())
153153
->method($handlerMethodName)
154154
->willReturn($innerHandler);
155155

156156
$contentHandlerMock
157-
->expects($this->once())
157+
->expects(self::once())
158158
->method('listVersions')
159159
->with($contentId)
160160
->willReturn(
@@ -163,13 +163,13 @@ public function testTrashSubtree()
163163
]
164164
);
165165
$innerHandler
166-
->expects($this->once())
166+
->expects(self::once())
167167
->method('trashSubtree')
168168
->with($locationId)
169169
->willReturn(null);
170170

171171
$this->cacheIdentifierGeneratorMock
172-
->expects($this->exactly(4))
172+
->expects(self::exactly(4))
173173
->method('generateTag')
174174
->withConsecutive(
175175
['content_version', [$contentId, $versionNo], false],
@@ -180,7 +180,7 @@ public function testTrashSubtree()
180180
->willReturnOnConsecutiveCalls(...$tags);
181181

182182
$this->cacheMock
183-
->expects($this->once())
183+
->expects(self::once())
184184
->method('invalidateTags')
185185
->with($tags);
186186

0 commit comments

Comments
 (0)