3 namespace Drupal\Tests\comment\Kernel\Migrate;
5 use Drupal\comment\Entity\CommentType;
6 use Drupal\migrate\MigrateException;
7 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
8 use Drupal\migrate_drupal\Tests\StubTestTrait;
9 use Drupal\node\Entity\NodeType;
12 * Test stub creation for comment entities.
16 class MigrateCommentStubTest extends MigrateDrupalTestBase {
23 public static $modules = ['comment', 'node'];
28 protected function setUp() {
30 $this->installEntitySchema('comment');
31 $this->installEntitySchema('node');
32 // Make sure uid 0 is created (default uid for comments is 0).
33 $storage = \Drupal::entityManager()->getStorage('user');
34 // Insert a row for the anonymous user.
42 // Need at least one node type and comment type present.
44 'type' => 'testnodetype',
45 'name' => 'Test node type',
48 'id' => 'testcommenttype',
49 'label' => 'Test comment type',
50 'target_entity_type_id' => 'node',
55 * Tests creation of comment stubs.
57 public function testStub() {
59 // We expect an exception, because there's no node to reference.
60 $this->performStubTest('comment');
61 $this->fail('Expected exception has not been thrown.');
63 catch (MigrateException $e) {
64 $this->assertIdentical($e->getMessage(),
65 'Stubbing failed, unable to generate value for field entity_id');
68 // The stub should pass when there's a node to point to.
69 $this->createStub('node');
70 $this->performStubTest('comment');