You are here

protected function MigrateCommentStubTest::setUp in Drupal 8

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

Overrides MigrateDrupalTestBase::setUp

File

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

Class

MigrateCommentStubTest
Test stub creation for comment entities.

Namespace

Drupal\Tests\comment\Kernel\Migrate

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('comment');
  $this
    ->installEntitySchema('node');
  $this
    ->installSchema('system', [
    'sequences',
  ]);

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