You are here

protected function CommentTestBase::createCommentType in Drupal 8

Same name in this branch
  1. 8 core/modules/comment/src/Tests/CommentTestBase.php \Drupal\comment\Tests\CommentTestBase::createCommentType()
  2. 8 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()

Creates a comment 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 399

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\Tests\comment\Functional

Code

protected function createCommentType($label) {
  $bundle = CommentType::create([
    'id' => $label,
    'label' => $label,
    'description' => '',
    'target_entity_type_id' => 'node',
  ]);
  $bundle
    ->save();
  return $bundle;
}