You are here

protected function HierarchyNestedSetIntegrationTest::assertChildOrder 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::assertChildOrder()

Asserts children in given order.

Parameters

\PNX\NestedSet\Node $parent_node: Parent node.

\Drupal\Core\Entity\EntityInterface[] $entities: Array of entities keyed by label.

string[] $order: Array of titles in order.

Return value

\PNX\NestedSet\Node[] Children.

4 calls to HierarchyNestedSetIntegrationTest::assertChildOrder()
HierarchyNestedSetIntegrationTest::testNestedSetOrdering in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests ordered storage in nested set tables.
HierarchyNestedSetIntegrationTest::testNestedSetParentToChildWithSiblings in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving from out of tree, into tree with existing siblings.
HierarchyNestedSetIntegrationTest::testNestedSetResaveParent in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Test saving the parent after adding children.
HierarchyNestedSetIntegrationTest::testNestedSetStorageMoveParentWithSiblingOrdering in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving parents with weight ordering.

File

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

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

protected function assertChildOrder(Node $parent_node, array $entities, array $order) {
  $children = $this
    ->getChildren($parent_node);
  $this
    ->assertCount(count($order), $children);
  $this
    ->assertEquals(array_map(function ($name) use ($entities) {
    return $entities[$name]
      ->id();
  }, $order), array_map(function (Node $node) {
    return $node
      ->getId();
  }, $children));
  return $children;
}