You are here

protected function HierarchyNestedSetRevisionIntegrationTest::createTestEntity in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/HierarchyNestedSetRevisionIntegrationTest.php \Drupal\Tests\entity_hierarchy\Kernel\HierarchyNestedSetRevisionIntegrationTest::createTestEntity()

Creates a new test entity.

Parameters

int|null $parentId: Parent ID.

string $label: Entity label.

int $weight: Entity weight amongst sibling, if parent is set.

Return value

\Drupal\Core\Entity\EntityInterface New entity.

Overrides EntityHierarchyTestTrait::createTestEntity

1 call to HierarchyNestedSetRevisionIntegrationTest::createTestEntity()
HierarchyNestedSetRevisionIntegrationTest::doCreateChildTestEntity in tests/src/Kernel/HierarchyNestedSetRevisionIntegrationTest.php
Creates a new test entity.

File

tests/src/Kernel/HierarchyNestedSetRevisionIntegrationTest.php, line 48

Class

HierarchyNestedSetRevisionIntegrationTest
Tests integration with entity_hierarchy and a revisionable entity.

Namespace

Drupal\Tests\entity_hierarchy\Kernel

Code

protected function createTestEntity($parentId, $label = 'Child 1', $weight = 0, $withRevision = TRUE) {
  $entity = parent::createTestEntity($parentId, $label, $weight);
  if ($withRevision) {

    // Save it twice so we end up with another revision.
    $entity
      ->setNewRevision(TRUE);
    $entity
      ->save();
  }
  return $entity;
}