protected function CommentResourceTestBase::createEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php \Drupal\Tests\comment\Functional\Rest\CommentResourceTestBase::createEntity()
- 9 core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php \Drupal\Tests\comment\Functional\Rest\CommentResourceTestBase::createEntity()
File
- core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php, line 85
Class
- CommentResourceTestBase
Namespace
Drupal\Tests\comment\Functional\Rest
Code
protected function createEntity() {
$bundle = 'bar';
entity_test_create_bundle($bundle, NULL, 'entity_test');
$this
->addDefaultCommentField('entity_test', 'bar', 'comment');
$commented_entity = EntityTest::create([
'name' => 'Camelids',
'type' => 'bar',
]);
$commented_entity
->save();
$comment = Comment::create([
'comment_body' => [
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
'format' => 'plain_text',
],
'entity_id' => $commented_entity
->id(),
'entity_type' => 'entity_test',
'field_name' => 'comment',
]);
$comment
->setSubject('Llama')
->setOwnerId(static::$auth ? $this->account
->id() : 0)
->setPublished()
->setCreatedTime(123456789)
->setChangedTime(123456789);
$comment
->save();
return $comment;
}