protected function NodeTest::createEntity in JSON:API 8
Same name and namespace in other branches
- 8.2 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
- tests/
src/ Functional/ NodeTest.php, line 93
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(TRUE)
->setCreatedTime(123456789)
->setChangedTime(123456789)
->setRevisionCreationTime(123456789)
->set('path', '/llama')
->save();
return $node;
}