Skip to content

Commit

Permalink
fix: Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Apr 25, 2024
1 parent 84a16b0 commit 07d6721
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Legacy/Content/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public function convertToStorageValue(Field $field)
*
* "$tableName_$columnName"
*
* @param array $rows
* @param array $nameRows
* @param array<array<string, scalar>> $rows
* @param array<array<string, scalar>> $nameRows
* @param string $prefix
*
* @return \eZ\Publish\SPI\Persistence\Content[]
Expand Down
9 changes: 5 additions & 4 deletions src/contracts/FieldType/DefaultDataFieldStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
interface DefaultDataFieldStorage
{
/**
* Populates $field value property with default data based on the external data.
* $field->value is a {@link \eZ\Publish\SPI\Persistence\Content\FieldValue} object.
* This value holds the data as a {@link \eZ\Publish\Core\FieldType\Value} based object, according to
* the field type (e.g. for TextLine, it will be a {@link \eZ\Publish\Core\FieldType\TextLine\Value} object).
* Populates <code>$field</code> value property with default data based on the external data.
*
* <code>$field->value</code> is a {@see \eZ\Publish\SPI\Persistence\Content\FieldValue} object.
* This value holds the data as a {@see \eZ\Publish\Core\FieldType\Value} based object, according to
* the field type (e.g. for <code>TextLine</code>, it will be a {@see \eZ\Publish\Core\FieldType\TextLine\Value} object).
*/
public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ public function testResolveVirtualField(): void
$converterRegistry = $this->getConverterRegistry();

$storageRegistry = $this->createMock(StorageRegistry::class);
$storageRegistry->method('getStorage')
->willReturn(new NullStorage());
$storageRegistry->method('getStorage')->willReturn(new NullStorage());

$contentGateway = $this->createMock(ContentGateway::class);
$contentGateway->expects($this->never())
->method('insertNewField');
$contentGateway->expects($this->never())->method('insertNewField');

$eventDispatcher = $this->getEventDispatcher(
$converterRegistry,
Expand Down Expand Up @@ -126,8 +124,7 @@ public function getIndexData(VersionInfo $versionInfo, Field $field, array $cont
});

$contentGateway = $this->createMock(ContentGateway::class);
$contentGateway->expects($this->never())
->method('insertNewField');
$contentGateway->expects($this->never())->method('insertNewField');

$eventDispatcher = $this->getEventDispatcher(
$converterRegistry,
Expand Down Expand Up @@ -178,8 +175,7 @@ public function testPersistEmptyExternalStorageField(): void
$converterRegistry = $this->getConverterRegistry();

$storage = $this->createMock(FieldStorage::class);
$storage->expects($this->never())
->method('storeFieldData');
$storage->expects($this->never())->method('storeFieldData');

$storage->expects($this->once())
->method('getFieldData')
Expand All @@ -190,12 +186,10 @@ public function testPersistEmptyExternalStorageField(): void
});

$storageRegistry = $this->createMock(StorageRegistry::class);
$storageRegistry->method('getStorage')
->willReturn($storage);
$storageRegistry->method('getStorage')->willReturn($storage);

$contentGateway = $this->createMock(ContentGateway::class);
$contentGateway->expects($this->once())
->method('insertNewField')
$contentGateway->expects($this->once())->method('insertNewField')
->willReturn(567);

$eventDispatcher = $this->getEventDispatcher(
Expand Down Expand Up @@ -257,16 +251,13 @@ public function testPersistExternalStorageField(): void
$field->value->externalData = $field->value->data;
});

$storage->expects($this->once())
->method('getFieldData');
$storage->expects($this->once())->method('getFieldData');

$storageRegistry = $this->createMock(StorageRegistry::class);
$storageRegistry->method('getStorage')
->willReturn($storage);
$storageRegistry->method('getStorage')->willReturn($storage);

$contentGateway = $this->createMock(ContentGateway::class);
$contentGateway->expects($this->once())
->method('insertNewField')
$contentGateway->expects($this->once())->method('insertNewField')
->willReturn(456);

$eventDispatcher = $this->getEventDispatcher(
Expand Down

0 comments on commit 07d6721

Please sign in to comment.