public function TextItemFieldDependencyCollectorTest::testFieldsAndEditorWereAddedAsDependencies in Dependency Calculation 8
@covers ::onCalculateDependencies
Throws
\Exception
File
- tests/
src/ Kernel/ EventSubscriber/ DependencyCollector/ TextItemFieldDependencyCollectorTest.php, line 84
Class
- TextItemFieldDependencyCollectorTest
- Class TextItemFieldDependencyCollectorTest.
Namespace
Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollectorCode
public function testFieldsAndEditorWereAddedAsDependencies() {
$editor = Editor::create([
'format' => 'plain_text',
'editor' => 'unicorn',
]);
$editor
->save();
$vocabulary = $this
->createVocabulary();
$vocabulary_target = $this
->createVocabulary();
$handler_settings = [
'target_bundles' => [
$vocabulary_target
->id() => $vocabulary_target
->id(),
],
];
$this
->createEntityReferenceField('taxonomy_term', $vocabulary
->id(), 'type', $this
->randomString(), 'taxonomy_term', 'default', $handler_settings);
$entity_display_repository = \Drupal::service('entity_display.repository');
$entity_display_repository
->getViewDisplay('taxonomy_term', $vocabulary
->id(), 'default')
->setComponent('type')
->save();
$entity_display_repository
->getFormDisplay('taxonomy_term', $vocabulary
->id(), 'default')
->setComponent('type', [
'type' => 'entity_reference_autocomplete',
])
->save();
$term1 = $this
->createTerm($vocabulary);
$term2 = $this
->createTerm($vocabulary_target);
$term1
->set('type', $term2
->id());
$term1
->save();
$event = $this
->dispatchCalculateDependencies($term1);
$dependencies = $event
->getDependencies();
$filter_uuid = \Drupal::entityTypeManager()
->getStorage('filter_format')
->load('plain_text')
->uuid();
$this
->assertArrayHasKey($filter_uuid, $dependencies);
$this
->assertArrayHasKey($editor
->uuid(), $dependencies);
}