You are here

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

Test parent/child relationship.

Parameters

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

\Drupal\Core\Entity\EntityInterface $parent: (optional) Parent to test relationship with, defaults to the one created in setup if not passed.

int $baseDepth: (optional) Base depth to add, defaults to 0.

9 calls to HierarchyNestedSetIntegrationTest::assertSimpleParentChild()
HierarchyNestedSetIntegrationTest::testDeleteChildWithGrandChildren in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests deleting child node with grandchildren.
HierarchyNestedSetIntegrationTest::testNestedSetParentToChild in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving from out of tree, into tree.
HierarchyNestedSetIntegrationTest::testNestedSetStorageMoveParent in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving parents.
HierarchyNestedSetIntegrationTest::testNestedSetStorageMoveParentWithChildren in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving tree.
HierarchyNestedSetIntegrationTest::testNestedSetStorageMoveParentWithSiblingOrdering in tests/src/Kernel/HierarchyNestedSetIntegrationTest.php
Tests moving parents with weight ordering.

... See full list

File

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

Class

HierarchyNestedSetIntegrationTest
Tests integration with entity_hierarchy.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

protected function assertSimpleParentChild(EntityInterface $child, EntityInterface $parent = NULL, $baseDepth = 0) {
  $parent = $parent ?: $this->parent;
  $root_node = $this->treeStorage
    ->getNode($this->nodeFactory
    ->fromEntity($parent));
  $this
    ->assertNotEmpty($root_node);
  $this
    ->assertEquals($parent
    ->id(), $root_node
    ->getId());
  $this
    ->assertEquals($this
    ->getEntityRevisionId($parent), $root_node
    ->getRevisionId());
  $this
    ->assertEquals(0 + $baseDepth, $root_node
    ->getDepth());
  $children = $this
    ->getChildren($root_node);
  $this
    ->assertCount(1, $children);
  $first = reset($children);
  $this
    ->assertEquals($child
    ->id(), $first
    ->getId());
  $this
    ->assertEquals($this
    ->getEntityRevisionId($child), $first
    ->getRevisionId());
  $this
    ->assertEquals(1 + $baseDepth, $first
    ->getDepth());
}