You are here

public function HierarchyNestedSetIntegrationTest::testRemoveParentReference in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/HierarchyNestedSetIntegrationTest.php \Drupal\Tests\entity_hierarchy\Kernel\HierarchyNestedSetIntegrationTest::testRemoveParentReference()

Tests removing parent reference.

File

tests/src/Kernel/HierarchyNestedSetIntegrationTest.php, line 55

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

public function testRemoveParentReference() {
  $child = $this
    ->createTestEntity($this->parent
    ->id());
  $root_node = $this->treeStorage
    ->getNode($this->parentStub);
  $this
    ->assertSimpleParentChild($child);
  $child
    ->set(static::FIELD_NAME, NULL);
  $child
    ->save();
  $children = $this
    ->getChildren($root_node);
  $this
    ->assertCount(0, $children);
  $child_node = $this->treeStorage
    ->getNode($this->nodeFactory
    ->fromEntity($child));
  $this
    ->assertEquals(0, $child_node
    ->getDepth());
}