public function LayoutBuilderDependencyCalculatorTest::testEntityDependencies in Dependency Calculation 8
Tests the calculation of Layout Builder dependencies.
File
- tests/
src/ Kernel/ EventSubscriber/ LayoutBuilderDependencyCalculatorTest.php, line 133
Class
- LayoutBuilderDependencyCalculatorTest
- Class LayoutBuilderDependencyCalculatorTest.
Namespace
Drupal\Tests\depcalc\KernelCode
public function testEntityDependencies() {
$view = \Drupal::entityTypeManager()
->getStorage('view')
->load('who_s_online');
// Calculate dependencies for an entity_view_display entity.
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = \Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load('node.landing_page.default');
// Extract the entity dependencies.
$actual_entities = $this
->getEntityDependencies($entity);
// Test that our inline block is found.
$this
->assertTrue(in_array('f523731a-cb0a-44be-8f9d-a4fae4dd7015', $actual_entities));
// Test that our regular content block was also found.
$this
->assertTrue(in_array('865b56c1-134c-401e-88bc-f37d36dbc885', $actual_entities));
// Test that our placed view is a dependency.
$this
->assertTrue(in_array($view
->uuid(), $actual_entities));
$actual_modules = $this
->getModuleDependencies($entity);
$this
->assertEqual($actual_modules, [
'user',
'block_content',
'layout_builder',
'layout_discovery',
'views',
'text',
]);
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load(1);
// Extract the entity dependencies.
$actual_entities = $this
->getEntityDependencies($node);
// Test that our inline block is found.
$this
->assertTrue(in_array('f523731a-cb0a-44be-8f9d-a4fae4dd7015', $actual_entities));
// Test that our regular content block was also found.
$this
->assertTrue(in_array('865b56c1-134c-401e-88bc-f37d36dbc885', $actual_entities));
// Test that our placed view is a dependency.
$this
->assertTrue(in_array($view
->uuid(), $actual_entities));
$actual_modules = $this
->getModuleDependencies($node);
$this
->assertEqual($actual_modules, [
'node',
'layout_discovery',
'block_content',
'text',
'layout_builder',
'user',
'views',
]);
}