Skip to content

Commit

Permalink
WIP: Part II (Circular-reference)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Nov 28, 2023
1 parent 899df62 commit 6cdb859
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 19 additions & 5 deletions tests/lib/Persistence/Legacy/Content/MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -508,7 +509,8 @@ protected function getMapper($valueConverter = null)
{
return new Mapper(
$this->getValueConverterRegistryMock(),
$this->getLanguageHandler()
$this->getLanguageHandler(),
$this->getContentTypeHandler()
);
}

Expand Down Expand Up @@ -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');
1 change: 1 addition & 0 deletions tests/lib/Search/Legacy/Content/HandlerContentSortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected function getContentMapperMock()
[
$this->getFieldRegistry(),
$this->getLanguageHandler(),
$this->getContentTypeHandler(),
]
)
->setMethods(['extractContentInfoFromRows'])
Expand Down
1 change: 1 addition & 0 deletions tests/lib/Search/Legacy/Content/HandlerContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ protected function getContentMapperMock()
[
$this->getConverterRegistry(),
$this->getLanguageHandler(),
$this->getContentTypeHandler(),
]
)
->setMethods(['extractContentInfoFromRows'])
Expand Down

0 comments on commit 6cdb859

Please sign in to comment.