From 6cdb8597e3dac618d6fd793bba3cbe3aef58cf93 Mon Sep 17 00:00:00 2001 From: Nattfarinn Date: Tue, 28 Nov 2023 10:24:40 +0100 Subject: [PATCH] WIP: Part II (Circular-reference) --- .../Type/Update/Handler/DoctrineDatabase.php | 11 ++------- .../Persistence/Legacy/Content/MapperTest.php | 24 +++++++++++++++---- .../Legacy/Content/HandlerContentSortTest.php | 1 + .../Legacy/Content/HandlerContentTest.php | 1 + 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/lib/Persistence/Legacy/Content/Type/Update/Handler/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Type/Update/Handler/DoctrineDatabase.php index 15d3d38558..0f5fd63171 100644 --- a/src/lib/Persistence/Legacy/Content/Type/Update/Handler/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Type/Update/Handler/DoctrineDatabase.php @@ -23,21 +23,14 @@ final class DoctrineDatabase extends Handler /** @var \Ibexa\Core\Persistence\Legacy\Content\Type\Gateway */ protected $contentTypeGateway; - /** @var \Ibexa\Core\Persistence\Legacy\Content\Type\ContentUpdater */ - protected $contentUpdater; - - public function __construct(Gateway $contentTypeGateway, ContentUpdater $contentUpdater) + public function __construct(Gateway $contentTypeGateway) { $this->contentTypeGateway = $contentTypeGateway; - $this->contentUpdater = $contentUpdater; } public function updateContentObjects(Type $fromType, Type $toType): void { - $this->contentUpdater->applyUpdates( - $fromType->id, - $this->contentUpdater->determineActions($fromType, $toType) - ); + // Do nothing, content objects are no longer updated } public function deleteOldType(Type $fromType): void diff --git a/tests/lib/Persistence/Legacy/Content/MapperTest.php b/tests/lib/Persistence/Legacy/Content/MapperTest.php index 806767f9e4..7f8dbd3ebd 100644 --- a/tests/lib/Persistence/Legacy/Content/MapperTest.php +++ b/tests/lib/Persistence/Legacy/Content/MapperTest.php @@ -140,7 +140,7 @@ public function testConvertToStorageValue() $field->type = 'some-type'; $field->value = new FieldValue(); - $mapper = new Mapper($reg, $this->getLanguageHandler()); + $mapper = new Mapper($reg, $this->getLanguageHandler(), $this->getContentTypeHandler()); $res = $mapper->convertToStorageValue($field); $this->assertInstanceOf( @@ -178,7 +178,7 @@ public function testExtractContentFromRows() ] ); - $mapper = new Mapper($reg, $this->getLanguageHandler()); + $mapper = new Mapper($reg, $this->getLanguageHandler(), $this->getContentTypeHandler()); $result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture); $this->assertEquals( @@ -206,7 +206,7 @@ public function testExtractContentFromRowsMultipleVersions() $rowsFixture = $this->getMultipleVersionsExtractFixture(); $nameRowsFixture = $this->getMultipleVersionsNamesExtractFixture(); - $mapper = new Mapper($reg, $this->getLanguageHandler()); + $mapper = new Mapper($reg, $this->getLanguageHandler(), $this->getContentTypeHandler()); $result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture); $this->assertCount( @@ -351,7 +351,8 @@ public function testExtractContentInfoFromRow(array $fixtures, $prefix) $contentInfoReference = $this->getContentExtractReference()->versionInfo->contentInfo; $mapper = new Mapper( $this->getValueConverterRegistryMock(), - $this->getLanguageHandler() + $this->getLanguageHandler(), + $this->getContentTypeHandler() ); self::assertEquals($contentInfoReference, $mapper->extractContentInfoFromRow($fixtures, $prefix)); } @@ -508,7 +509,8 @@ protected function getMapper($valueConverter = null) { return new Mapper( $this->getValueConverterRegistryMock(), - $this->getLanguageHandler() + $this->getLanguageHandler(), + $this->getContentTypeHandler() ); } @@ -603,6 +605,18 @@ static function ($languageCode) use ($languages) { return $this->languageHandler; } + + protected function getContentTypeHandler(): Content\Type\Handler + { + $mock = $this->createMock(Content\Type\Handler::class); + $mock + ->method('load') + ->willReturn( + $this->createMock(Content\Type::class) + ); + + return $mock; + } } class_alias(MapperTest::class, 'eZ\Publish\Core\Persistence\Legacy\Tests\Content\MapperTest'); diff --git a/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php b/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php index 1194ceb488..a5fdb7eb59 100644 --- a/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php @@ -101,6 +101,7 @@ protected function getContentMapperMock() [ $this->getFieldRegistry(), $this->getLanguageHandler(), + $this->getContentTypeHandler(), ] ) ->setMethods(['extractContentInfoFromRows']) diff --git a/tests/lib/Search/Legacy/Content/HandlerContentTest.php b/tests/lib/Search/Legacy/Content/HandlerContentTest.php index b5166e9a09..c4c279ef3f 100644 --- a/tests/lib/Search/Legacy/Content/HandlerContentTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerContentTest.php @@ -200,6 +200,7 @@ protected function getContentMapperMock() [ $this->getConverterRegistry(), $this->getLanguageHandler(), + $this->getContentTypeHandler(), ] ) ->setMethods(['extractContentInfoFromRows'])