You are here

protected function NodeResourceTestBase::createEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::createEntity()
  2. 9 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::createEntity()
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 71

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