Skip to content

Commit 90831c6

Browse files
committed
[Tests] Improved mocking of DefaultDataFieldStorage
1 parent 0b0ba22 commit 90831c6

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php

+9-32
Original file line numberDiff line numberDiff line change
@@ -85,42 +85,19 @@ public function testResolveVirtualExternalStorageField(): void
8585
$contentGateway = $this->createMock(ContentGateway::class);
8686
$contentGateway->expects($this->never())->method('insertNewField');
8787

88-
$storageRegistry = $this->createMock(StorageRegistry::class);
89-
$storageRegistry->method('getStorage')
90-
// Multiple interface mocks are deprecated in PHPUnit 9+
91-
->willReturn(new class() implements FieldStorage, DefaultDataFieldStorage {
92-
public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): void
93-
{
88+
$defaultFieldStorageMock = $this->createMock(DefaultDataFieldStorage::class);
89+
$defaultFieldStorageMock
90+
->method('getDefaultFieldData')
91+
->willReturnCallback(
92+
static function (VersionInfo $versionInfo, Field $field): void {
9493
$field->value->externalData = [
9594
'some_default' => 'external_data',
9695
];
9796
}
98-
99-
public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context): void
100-
{
101-
// Mock
102-
}
103-
104-
public function getFieldData(VersionInfo $versionInfo, Field $field, array $context): void
105-
{
106-
// Mock
107-
}
108-
109-
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context): void
110-
{
111-
// Mock
112-
}
113-
114-
public function hasFieldData(): void
115-
{
116-
// Mock
117-
}
118-
119-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): void
120-
{
121-
// Mock
122-
}
123-
});
97+
);
98+
$storageRegistry = $this->createMock(StorageRegistry::class);
99+
$storageRegistry->method('getStorage')
100+
->willReturn($defaultFieldStorageMock);
124101

125102
$eventDispatcher = $this->getEventDispatcher(
126103
$converterRegistry,

0 commit comments

Comments
 (0)