Skip to content

Commit

Permalink
fixup! IBX-1580: External storage for field type settings
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Dec 4, 2021
1 parent 960f6a8 commit 7888be9
Showing 1 changed file with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,12 @@ public function testAddFieldDefinition()

$fieldDef = new FieldDefinition();

$storageDispatcherMock = $this->getStorageDispatcherMock();
$storageDispatcherMock
->expects($this->once())
->method('storeFieldConstraintsData')
->with($fieldDef);

$handler = $this->getHandler();
$handler->addFieldDefinition(23, 1, $fieldDef);

Expand Down Expand Up @@ -901,6 +907,12 @@ public function testGetContentCount()

public function testRemoveFieldDefinition()
{
$storageDispatcherMock = $this->getStorageDispatcherMock();
$storageDispatcherMock
->expects($this->once())
->method('deleteFieldConstraintsData')
->with('ezstring', 42);

$gatewayMock = $this->getGatewayMock();
$gatewayMock->expects($this->once())
->method('deleteFieldDefinition')
Expand All @@ -918,37 +930,32 @@ public function testRemoveFieldDefinition()

public function testUpdateFieldDefinition()
{
$fieldDef = new FieldDefinition();

$mapperMock = $this->getMapperMock(
['toStorageFieldDefinition']
);
$mapperMock->expects($this->once())
->method('toStorageFieldDefinition')
->with(
$this->isInstanceOf(
FieldDefinition::class
),
$this->isInstanceOf(
StorageFieldDefinition::class
)
);
->with($fieldDef, $this->isInstanceOf(StorageFieldDefinition::class));

$gatewayMock = $this->getGatewayMock();
$gatewayMock->expects($this->once())
->method('updateFieldDefinition')
->with(
$this->equalTo(23),
$this->equalTo(1),
$this->isInstanceOf(
FieldDefinition::class
)
$fieldDef
);

$fieldDef = new FieldDefinition();
$storageDispatcherMock = $this->getStorageDispatcherMock();
$storageDispatcherMock
->expects($this->once())
->method('storeFieldConstraintsData')
->with($fieldDef);

$handler = $this->getHandler();
$res = $handler->updateFieldDefinition(23, 1, $fieldDef);

$this->assertNull($res);
$handler->updateFieldDefinition(23, 1, $fieldDef);
}

public function testPublish()
Expand Down Expand Up @@ -1115,6 +1122,9 @@ public function getUpdateHandlerMock()
return $this->updateHandlerMock;
}

/**
* @return \Ibexa\Core\Persistence\Legacy\Content\Type\StorageDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject
*/
public function getStorageDispatcherMock(): StorageDispatcherInterface
{
if (!isset($this->storageDispatcherMock)) {
Expand Down

0 comments on commit 7888be9

Please sign in to comment.