function CommentBundlesTest::setUp

Same name and namespace in other branches
  1. 8.9.x 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()
  3. 11.x 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();
    }
}

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