protected function NodeTest::createEntity in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/NodeTest.php \Drupal\Tests\jsonapi\Functional\NodeTest::createEntity()
Creates the entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface The entity to be tested.
Overrides ResourceTestBase::createEntity
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ NodeTest.php, line 114
Class
- NodeTest
- JSON:API integration test for the "Node" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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($this->account
->id())
->setPublished()
->setCreatedTime(123456789)
->setChangedTime(123456789)
->setRevisionCreationTime(123456789)
->set('path', '/llama')
->save();
return $node;
}