function WorkspaceTestTrait::createEntity

Creates an entity.

Parameters

string $entity_type_id: The entity type ID.

array $values: An array of values for the entity.

Return value

\Drupal\Core\Entity\EntityInterface The created entity.

1 call to WorkspaceTestTrait::createEntity()
WorkspaceAssociationTest::testWorkspaceAssociation in core/modules/workspaces/tests/src/Kernel/WorkspaceAssociationTest.php
Tests the revisions tracked by a workspace.
1 method overrides WorkspaceTestTrait::createEntity()
WorkspacesContentModerationStateTest::createEntity in core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php
Creates an entity.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php, line 178

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function createEntity(string $entity_type_id, array $values = []) : EntityInterface {
    $storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
    $entity = $storage->create($values);
    $entity->save();
    return $entity;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.