function CommentTestBase::createCommentType
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
- 8.9.x core/modules/comment/src/Tests/CommentTestBase.php \Drupal\comment\Tests\CommentTestBase::createCommentType()
- 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
- 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
Creates a comment type (bundle).
Parameters
string $label: The comment type label.
Return value
\Drupal\comment\Entity\CommentType Created comment type.
2 calls to CommentTestBase::createCommentType()
- CommentTypeTest::testCommentTypeCreation in core/
modules/ comment/ tests/ src/ Functional/ CommentTypeTest.php - Tests creating a comment type programmatically and via a form.
- CommentTypeTest::testCommentTypeDeletion in core/
modules/ comment/ tests/ src/ Functional/ CommentTypeTest.php - Tests deleting a comment type that still has content.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentTestBase.php, line 405
Class
- CommentTestBase
- Provides setup and helper methods for comment tests.
Namespace
Drupal\Tests\comment\FunctionalCode
protected function createCommentType($label) {
$bundle = CommentType::create([
'id' => $label,
'label' => $label,
'description' => '',
'target_entity_type_id' => 'node',
]);
$bundle->save();
return $bundle;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.