public function DependencyCalculatorTest::testEntityDependencies in Dependency Calculation 8
Tests the calculation of entity dependencies.
@dataProvider entityDependenciesDataProvider
Parameters
string $entity_type: The entity type.
array $entities: Entities to create.
array $expected_entities: The list of expected entities.
array $expected_modules: The list of expected modules.
Throws
\Exception
File
- tests/
src/ Kernel/ DependencyCalculatorTest.php, line 124
Class
- DependencyCalculatorTest
- Class DependencyCalculatorTest.
Namespace
Drupal\Tests\depcalc\KernelCode
public function testEntityDependencies(string $entity_type, array $entities, array $expected_entities, array $expected_modules) {
foreach ($entities as $entity_values) {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = Drupal::service('entity_type.manager');
$entity = $entity_type_manager
->getStorage($entity_type)
->create($entity_values);
$entity
->save();
}
// Calculate dependencies for the last entity from the $entities list.
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$actual_entities = $this
->getEntityDependencies($entity);
$this
->assertEqual($actual_entities, $expected_entities);
$actual_modules = $this
->getModuleDependencies($entity);
$this
->assertEqual($actual_modules, $expected_modules);
}