You are here

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

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 ViewsRevisionableIntegrationTest::createTestEntity()
ViewsRevisionableIntegrationTest::doCreateChildTestEntity in tests/src/Kernel/ViewsRevisionableIntegrationTest.php
Creates a new test entity.

File

tests/src/Kernel/ViewsRevisionableIntegrationTest.php, line 61

Class

ViewsRevisionableIntegrationTest
Defines a class for testing views integration with revisionable entities.

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;
}