public function LinkFieldCollectorTest::testLinkFieldCollectorDeletedReference in Dependency Calculation 8
Test dependency calculation.
Checks the node's dependencies contains entities which have been deleted.
File
- tests/
src/ Kernel/ EventSubscriber/ DependencyCollector/ LinkFieldCollectorTest.php, line 169
Class
- LinkFieldCollectorTest
- Class LinkFieldCollectorTest to check Link field dependencies.
Namespace
Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollectorCode
public function testLinkFieldCollectorDeletedReference() {
$node = $this
->drupalCreateNode([]);
$linked_node = $this
->drupalCreateNode([]);
$id = $linked_node
->id();
$node
->get('link')
->appendItem([
'uri' => "entity:node/{$id}",
'title' => $linked_node
->label(),
]);
$node
->save();
try {
$wrapper = new DependentEntityWrapper($node);
} catch (\Exception $exception) {
$this
->markTestIncomplete($exception
->getMessage());
}
$dependencies = $this->calculator
->calculateDependencies($wrapper, new DependencyStack());
$this
->assertArrayHasKey($linked_node
->uuid(), $dependencies);
$linked_node
->delete();
try {
$wrapper = new DependentEntityWrapper($node);
} catch (\Exception $exception) {
$this
->markTestIncomplete($exception
->getMessage());
}
$dependencies = $this->calculator
->calculateDependencies($wrapper, new DependencyStack());
$this
->assertArrayNotHasKey($linked_node
->uuid(), $dependencies);
}