diff --git a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php index 1312f40c80..750d5569e1 100644 --- a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php +++ b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionListener; +use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Tests\UnitTestCase; @@ -67,8 +68,9 @@ protected function setUp() { $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class); $this->cacheBackend = $this->prophesize(CacheBackendInterface::class); + $this->deletedFieldsRepository = $this->prophesize(\Drupal\Core\Field\DeletedFieldsRepositoryInterface::class); - $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldManager->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal()); + $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldManager->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal(), $this->deletedFieldsRepository->reveal()); } /** @@ -196,13 +198,16 @@ public function testOnFieldDefinitionUpdate() { * @covers ::onFieldDefinitionDelete */ public function testOnFieldDefinitionDeleteMultipleBundles() { + $storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class); $field_definition = $this->prophesize(FieldDefinitionInterface::class); $field_definition->getTargetEntityTypeId()->willReturn('test_entity_type'); $field_definition->getTargetBundle()->willReturn('test_bundle'); $field_definition->getName()->willReturn('test_field'); + $field_definition->getFieldStorageDefinition()->willReturn($storage_definition->reveal()); $storage = $this->prophesize(DynamicallyFieldableEntityStorageInterface::class); $storage->onFieldDefinitionDelete($field_definition->reveal())->shouldBeCalledTimes(1); + $storage->countFieldData($storage_definition->reveal(), TRUE)->willReturn(FALSE); $this->entityTypeManager->getStorage('test_entity_type')->willReturn($storage->reveal()); $entity = $this->prophesize(EntityTypeInterface::class); @@ -236,13 +241,16 @@ public function testOnFieldDefinitionDeleteMultipleBundles() { * @covers ::onFieldDefinitionDelete */ public function testOnFieldDefinitionDeleteSingleBundles() { + $storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class); $field_definition = $this->prophesize(FieldDefinitionInterface::class); $field_definition->getTargetEntityTypeId()->willReturn('test_entity_type'); $field_definition->getTargetBundle()->willReturn('test_bundle'); $field_definition->getName()->willReturn('test_field'); + $field_definition->getFieldStorageDefinition()->willReturn($storage_definition->reveal()); $storage = $this->prophesize(DynamicallyFieldableEntityStorageInterface::class); $storage->onFieldDefinitionDelete($field_definition->reveal())->shouldBeCalledTimes(1); + $storage->countFieldData($storage_definition->reveal(), TRUE)->willReturn(FALSE); $this->entityTypeManager->getStorage('test_entity_type')->willReturn($storage->reveal()); $entity = $this->prophesize(EntityTypeInterface::class);