public function CommentBaseFieldTest::testCommentBaseField in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Kernel/CommentBaseFieldTest.php \Drupal\Tests\comment\Kernel\CommentBaseFieldTest::testCommentBaseField()
Tests comment as a base field.
File
- core/
modules/ comment/ tests/ src/ Kernel/ CommentBaseFieldTest.php, line 40
Class
- CommentBaseFieldTest
- Tests that comment as a base field.
Namespace
Drupal\Tests\comment\KernelCode
public function testCommentBaseField() {
// Verify entity creation.
$entity = CommentTestBaseField::create([
'name' => $this
->randomMachineName(),
'test_comment' => CommentItemInterface::OPEN,
]);
$entity
->save();
$comment = Comment::create([
'entity_id' => $entity
->id(),
'entity_type' => 'comment_test_base_field',
'field_name' => 'test_comment',
'pid' => 0,
'uid' => 0,
'status' => CommentInterface::PUBLISHED,
'subject' => $this
->randomMachineName(),
'hostname' => '127.0.0.1',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'comment_body' => [
[
'value' => $this
->randomMachineName(),
],
],
]);
$comment
->save();
$this
->assertEquals('test_comment_type', $comment
->bundle());
}