function MigrateCommentStubTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php \Drupal\Tests\comment\Kernel\Migrate\MigrateCommentStubTest::setUp()
  2. 8.9.x core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php \Drupal\Tests\comment\Kernel\Migrate\MigrateCommentStubTest::setUp()
  3. 11.x core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php \Drupal\Tests\comment\Kernel\Migrate\MigrateCommentStubTest::setUp()

Overrides MigrateDrupalTestBase::setUp

File

core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php, line 29

Class

MigrateCommentStubTest
Test stub creation for comment entities.

Namespace

Drupal\Tests\comment\Kernel\Migrate

Code

protected function setUp() : void {
  parent::setUp();
  $this->installEntitySchema('comment');
  $this->installEntitySchema('node');
  // Make sure uid 0 is created (default uid for comments is 0).
  $storage = \Drupal::entityTypeManager()->getStorage('user');
  // Insert a row for the anonymous user.
  $storage->create([
    'uid' => 0,
    'status' => 0,
    'name' => '',
  ])
    ->save();
  // Need at least one node type and comment type present.
  NodeType::create([
    'type' => 'testnodetype',
    'name' => 'Test node type',
  ])->save();
  CommentType::create([
    'id' => 'testcommenttype',
    'label' => 'Test comment type',
    'target_entity_type_id' => 'node',
  ])->save();
}

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