You are here

public function EntityReferenceRevisionsCompositeTest::testCompositeDeleteAfterRemovingReference in Entity Reference Revisions 8

Tests the composite entity is deleted after removing its reference.

File

tests/src/Kernel/EntityReferenceRevisionsCompositeTest.php, line 489

Class

EntityReferenceRevisionsCompositeTest
Tests the entity_reference_revisions composite relationship.

Namespace

Drupal\Tests\entity_reference_revisions\Kernel

Code

public function testCompositeDeleteAfterRemovingReference() {
  list($composite, $node) = $this
    ->assignCompositeToNode();

  // Remove reference to the composite entity from the node.
  $node
    ->set('composite_reference', NULL);
  $node
    ->save();

  // Verify that the composite entity is not yet removed after deleting the
  // parent.
  $node
    ->delete();
  $composite = EntityTestCompositeRelationship::load($composite
    ->id());
  $this
    ->assertNotNull($composite);

  // Verify that the composite entity is removed after running cron.
  $this->cron
    ->run();
  $composite = EntityTestCompositeRelationship::load($composite
    ->id());
  $this
    ->assertNull($composite);
}