You are here

public function HierarchyNestedSetIntegrationTest::testNestedSetParentToChildWithSiblings 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::testNestedSetParentToChildWithSiblings()

Tests moving from out of tree, into tree with existing siblings.

@group entity_hierarchy_ordering

File

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

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

public function testNestedSetParentToChildWithSiblings() {
  $child = $this
    ->createTestEntity(NULL, 'Once was a parent');
  $entities = $this
    ->createChildEntities($this->parent
    ->id());
  $entities[$child
    ->label()] = $child;
  $child->{static::FIELD_NAME} = [
    'target_id' => $this->parent
      ->id(),
    'weight' => -2,
  ];
  $child
    ->save();
  $this
    ->assertChildOrder($this->treeStorage
    ->getNode($this->parentStub), $entities, [
    'Child 5',
    'Child 4',
    'Child 3',
    'Child 2',
    'Once was a parent',
    'Child 1',
  ]);
}