function CommentBundlesTest::setUp

Same name in other branches
  1. 9 core/modules/comment/tests/src/Kernel/CommentBundlesTest.php \Drupal\Tests\comment\Kernel\CommentBundlesTest::setUp()
  2. 8.9.x core/modules/comment/tests/src/Kernel/CommentBundlesTest.php \Drupal\Tests\comment\Kernel\CommentBundlesTest::setUp()
  3. 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 37

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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.