You are here

public function HierarchyNestedSetIntegrationTest::testNestedSetStorageMoveParentWithChildren in Entity Reference Hierarchy 8.2

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

Tests moving tree.

File

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

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

public function testNestedSetStorageMoveParentWithChildren() {
  $child = $this
    ->createTestEntity($this->parent
    ->id(), 'Child 1', 1);
  $parent2 = $this
    ->createTestEntity(NULL, 'Parent 2');
  $grandchild = $this
    ->createTestEntity($child
    ->id(), 'Grandchild 1', 1);
  $this
    ->assertSimpleParentChild($child);
  $this
    ->assertSimpleParentChild($grandchild, $child, 1);
  $child
    ->set(static::FIELD_NAME, $parent2
    ->id());
  $child
    ->save();
  $this
    ->assertSimpleParentChild($child, $parent2);
  $this
    ->assertSimpleParentChild($grandchild, $child, 1);
}