diff --git a/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php b/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php index b091612861..9a4cae3f2b 100644 --- a/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php +++ b/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php @@ -61,11 +61,7 @@ public function testResolveVirtualField(): void $contentGateway->expects($this->never()) ->method('insertNewField'); - $eventDispatcher = new TraceableEventDispatcher( - new EventDispatcher(), - new Stopwatch() - ); - + $eventDispatcher = $this->getEventDispatcher(); $eventDispatcher->addSubscriber( new ResolveVirtualFieldSubscriber( $converterRegistry, @@ -123,6 +119,7 @@ public function testResolveVirtualExternalStorageField(): void $storageRegistry = $this->createMock(StorageRegistry::class); $storageRegistry->method('getStorage') + // Multiple interface mocks are deprecated in PHPUnit 9+ ->willReturn(new class() implements FieldStorage, DefaultDataFieldStorage { public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): void { @@ -133,42 +130,47 @@ public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): voi public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context): void { + // Mock } public function getFieldData(VersionInfo $versionInfo, Field $field, array $context): void { + // Mock } public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context): void { + // Mock } public function hasFieldData(): void { + // Mock } public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): void { + // Mock } }); - $eventDispatcher = new TraceableEventDispatcher( - new EventDispatcher(), - new Stopwatch() - ); + $contentGateway = $this->createMock(ContentGateway::class); + $contentGateway->expects($this->never()) + ->method('insertNewField'); + $eventDispatcher = $this->getEventDispatcher(); $eventDispatcher->addSubscriber( new ResolveVirtualFieldSubscriber( $converterRegistry, $storageRegistry, - $this->createMock(ContentGateway::class) + $contentGateway ) ); $content = $this->getContent(); $fieldDefinition = new FieldDefinition([ - 'id' => 123, - 'identifier' => 'example_field', + 'id' => 678, + 'identifier' => 'example_external_field', 'fieldType' => 'external_type_virtual', 'defaultValue' => new Content\FieldValue(), ]); @@ -183,7 +185,7 @@ public function getIndexData(VersionInfo $versionInfo, Field $field, array $cont $expected = new Content\Field([ 'id' => null, - 'fieldDefinitionId' => 123, + 'fieldDefinitionId' => 678, 'type' => 'external_type_virtual', 'value' => new Content\FieldValue([ 'externalData' => [ @@ -233,11 +235,7 @@ public function testPersistEmptyExternalStorageField(): void ->method('insertNewField') ->willReturn(567); - $eventDispatcher = new TraceableEventDispatcher( - new EventDispatcher(), - new Stopwatch() - ); - + $eventDispatcher = $this->getEventDispatcher(); $eventDispatcher->addSubscriber( new ResolveVirtualFieldSubscriber( $converterRegistry, @@ -316,11 +314,7 @@ public function testPersistExternalStorageField(): void ->method('insertNewField') ->willReturn(456); - $eventDispatcher = new TraceableEventDispatcher( - new EventDispatcher(), - new Stopwatch() - ); - + $eventDispatcher = $this->getEventDispatcher(); $eventDispatcher->addSubscriber( new ResolveVirtualFieldSubscriber( $converterRegistry, @@ -378,4 +372,12 @@ public function testPersistExternalStorageField(): void array_column($eventDispatcher->getCalledListeners(), 'pretty') ); } + + private function getEventDispatcher(): TraceableEventDispatcher + { + return new TraceableEventDispatcher( + new EventDispatcher(), + new Stopwatch() + ); + } }