You are here

protected function NodeResourceTestBase::createEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityResourceTestBase::createEntity

1 call to NodeResourceTestBase::createEntity()
ModeratedNodeResourceTestBase::createEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Creates the entity to be tested.
1 method overrides NodeResourceTestBase::createEntity()
ModeratedNodeResourceTestBase::createEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Creates the entity to be tested.

File

core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php, line 74

Class

NodeResourceTestBase

Namespace

Drupal\Tests\node\Functional\Rest

Code

protected function createEntity() {
  if (!NodeType::load('camelids')) {

    // Create a "Camelids" node type.
    NodeType::create([
      'name' => 'Camelids',
      'type' => 'camelids',
    ])
      ->save();
  }

  // Create a "Llama" node.
  $node = Node::create([
    'type' => 'camelids',
  ]);
  $node
    ->setTitle('Llama')
    ->setOwnerId(static::$auth ? $this->account
    ->id() : 0)
    ->setPublished()
    ->setCreatedTime(123456789)
    ->setChangedTime(123456789)
    ->setRevisionCreationTime(123456789)
    ->set('path', '/llama')
    ->save();
  return $node;
}