class CommentBaseFieldTest
Same name and namespace in other branches
- 11.x core/modules/comment/tests/src/Kernel/CommentBaseFieldTest.php \Drupal\Tests\comment\Kernel\CommentBaseFieldTest
- 10 core/modules/comment/tests/src/Kernel/CommentBaseFieldTest.php \Drupal\Tests\comment\Kernel\CommentBaseFieldTest
- 8.9.x core/modules/comment/tests/src/Kernel/CommentBaseFieldTest.php \Drupal\Tests\comment\Kernel\CommentBaseFieldTest
Tests that comment as a base field.
@group comment
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\comment\Kernel\CommentBaseFieldTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of CommentBaseFieldTest
File
-
core/
modules/ comment/ tests/ src/ Kernel/ CommentBaseFieldTest.php, line 17
Namespace
Drupal\Tests\comment\KernelView source
class CommentBaseFieldTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
'comment',
'comment_base_field_test',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('comment_test_base_field');
$this->installEntitySchema('comment');
$this->installSchema('system', [
'sequences',
]);
$this->installEntitySchema('user');
}
/**
* Tests comment as a base field.
*/
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());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.