3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
5 use Drupal\comment\CommentTypeInterface;
6 use Drupal\comment\Entity\CommentType;
7 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
10 * Tests migration of comment types from Drupal 7.
14 class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
16 public static $modules = ['node', 'comment', 'text', 'menu_ui'];
21 protected function setUp() {
23 $this->installConfig(static::$modules);
24 $this->executeMigrations([
31 * Asserts a comment type entity.
35 * @param string $label
38 protected function assertEntity($id, $label) {
39 $entity = CommentType::load($id);
40 $this->assertTrue($entity instanceof CommentTypeInterface);
41 /** @var \Drupal\comment\CommentTypeInterface $entity */
42 $this->assertIdentical($label, $entity->label());
43 $this->assertIdentical('node', $entity->getTargetEntityTypeId());
47 * Tests the migrated comment types.
49 public function testMigration() {
50 $this->assertEntity('comment_node_page', 'Basic page comment');
51 $this->assertEntity('comment_node_article', 'Article comment');
52 $this->assertEntity('comment_node_blog', 'Blog entry comment');
53 $this->assertEntity('comment_node_book', 'Book page comment');
54 $this->assertEntity('comment_node_forum', 'Forum topic comment');
55 $this->assertEntity('comment_node_test_content_type', 'Test content type comment');
57 $migration = $this->getMigration('d7_comment_type');
58 // Validate that the source count and processed count match up.
59 $this->assertIdentical($migration->getSourcePlugin()->count(), $migration->getIdMap()->processedCount());