public function FieldDefinitionListenerTest::testOnFieldDefinitionDeleteMultipleBundles in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php \Drupal\Tests\Core\Field\FieldDefinitionListenerTest::testOnFieldDefinitionDeleteMultipleBundles()
@covers ::onFieldDefinitionDelete
File
- core/
tests/ Drupal/ Tests/ Core/ Field/ FieldDefinitionListenerTest.php, line 201 - Contains \Drupal\Tests\Core\Field\FieldDefinitionListenerTest.
Class
- FieldDefinitionListenerTest
- @coversDefaultClass \Drupal\Core\Field\FieldDefinitionListener @group Field
Namespace
Drupal\Tests\Core\FieldCode
public function testOnFieldDefinitionDeleteMultipleBundles() {
$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');
$storage = $this
->prophesize(DynamicallyFieldableEntityStorageInterface::class);
$storage
->onFieldDefinitionDelete($field_definition
->reveal())
->shouldBeCalledTimes(1);
$this->entityTypeManager
->getStorage('test_entity_type')
->willReturn($storage
->reveal());
$entity = $this
->prophesize(EntityTypeInterface::class);
$this
->setUpEntityManager([
'test_entity_type' => $entity,
]);
// Set up the stored bundle field map.
$key_value_store = $this
->prophesize(KeyValueStoreInterface::class);
$this->keyValueFactory
->get('entity.definitions.bundle_field_map')
->willReturn($key_value_store
->reveal());
$key_value_store
->get('test_entity_type')
->willReturn([
'test_field' => [
'type' => 'test_type',
'bundles' => [
'test_bundle' => 'test_bundle',
],
],
'second_field' => [
'type' => 'test_type',
'bundles' => [
'test_bundle' => 'test_bundle',
],
],
]);
$key_value_store
->set('test_entity_type', [
'second_field' => [
'type' => 'test_type',
'bundles' => [
'test_bundle' => 'test_bundle',
],
],
])
->shouldBeCalled();
$this->fieldDefinitionListener
->onFieldDefinitionDelete($field_definition
->reveal());
}