protected function NodeResourceTestBase::createEntity in Drupal 9
Same name and namespace in other branches
- 8 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 71
Class
Namespace
Drupal\Tests\node\Functional\RestCode
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;
}