public function HierarchyNestedSetIntegrationTest::testNestedSetOrdering in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/HierarchyNestedSetIntegrationTest.php \Drupal\Tests\entity_hierarchy\Kernel\HierarchyNestedSetIntegrationTest::testNestedSetOrdering()
Tests ordered storage in nested set tables.
@group entity_hierarchy_ordering
File
- tests/
src/ Kernel/ HierarchyNestedSetIntegrationTest.php, line 28
Class
- HierarchyNestedSetIntegrationTest
- Tests integration with entity_hierarchy.
Namespace
Drupal\Tests\entity_hierarchy\KernelCode
public function testNestedSetOrdering() {
// Test for weight ordering of inserts.
$entities = $this
->createChildEntities($this->parent
->id());
$root_node = $this->treeStorage
->getNode($this->parentStub);
$this
->assertChildOrder($root_node, $entities, [
'Child 5',
'Child 4',
'Child 3',
'Child 2',
'Child 1',
]);
// Now insert one in the middle.
$name = 'Child 6';
$entities[$name] = $this
->createTestEntity($this->parent
->id(), $name, -2);
$this
->assertChildOrder($root_node, $entities, [
'Child 5',
'Child 4',
'Child 3',
'Child 2',
'Child 6',
'Child 1',
]);
}