You are here

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

Test parent/child relationship.

Parameters

\Drupal\Core\Entity\EntityInterface $child: Child node.

\Drupal\Core\Entity\EntityInterface $sibling: Sibling node.

1 call to HierarchyNestedSetIntegrationTest::assertParentWithTwoChildren()
HierarchyNestedSetIntegrationTest::testNestedSetStorageWithSiblingUpdate in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests saving with existing parent and sibling (no value change).

File

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

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

protected function assertParentWithTwoChildren(EntityInterface $child, EntityInterface $sibling) {
  $root_node = $this->treeStorage
    ->getNode($this->parentStub);
  $this
    ->assertNotEmpty($root_node);
  $this
    ->assertEquals($this->parent
    ->id(), $root_node
    ->getId());
  $this
    ->assertEquals($this
    ->getEntityRevisionId($this->parent), $root_node
    ->getRevisionId());
  $this
    ->assertEquals(0, $root_node
    ->getDepth());
  $children = $this
    ->getChildren($root_node);
  $this
    ->assertCount(2, $children);
  $first = reset($children);
  $this
    ->assertEquals($child
    ->id(), $first
    ->getId());
  $this
    ->assertEquals($this
    ->getEntityRevisionId($child), $first
    ->getRevisionId());
  $this
    ->assertEquals(1, $first
    ->getDepth());
  $last = end($children);
  $this
    ->assertEquals($sibling
    ->id(), $last
    ->getId());
  $this
    ->assertEquals($this
    ->getEntityRevisionId($sibling), $last
    ->getRevisionId());
  $this
    ->assertEquals(1, $last
    ->getDepth());
}