You are here

protected function CommentBundlesTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/tests/src/Kernel/CommentBundlesTest.php \Drupal\Tests\comment\Kernel\CommentBundlesTest::setUp()
  2. 10 core/modules/comment/tests/src/Kernel/CommentBundlesTest.php \Drupal\Tests\comment\Kernel\CommentBundlesTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/comment/tests/src/Kernel/CommentBundlesTest.php, line 35

Class

CommentBundlesTest
Tests that comment bundles behave as expected.

Namespace

Drupal\Tests\comment\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this->entityFieldManager = $this->container
    ->get('entity_field.manager');
  $this
    ->installEntitySchema('comment');

  // Create multiple comment bundles,
  // each of which has a different target entity type.
  $this->targetEntityTypes = [
    'comment' => 'Comment',
    'node' => 'Node',
    'taxonomy_term' => 'Taxonomy Term',
  ];
  foreach ($this->targetEntityTypes as $id => $label) {
    CommentType::create([
      'id' => 'comment_on_' . $id,
      'label' => 'Comment on ' . $label,
      'target_entity_type_id' => $id,
    ])
      ->save();
  }
}