MigrateCommentFieldTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Drupal\Tests\comment\Kernel\Migrate\d7;
  3. use Drupal\field\Entity\FieldStorageConfig;
  4. use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
  5. /**
  6. * Tests the migration of comment fields from Drupal 7.
  7. *
  8. * @group comment
  9. * @group migrate_drupal_7
  10. */
  11. class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static $modules = ['node', 'comment', 'text'];
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected function setUp() {
  20. parent::setUp();
  21. $this->migrateCommentTypes();
  22. $this->executeMigration('d7_comment_field');
  23. }
  24. /**
  25. * Asserts a comment field entity.
  26. *
  27. * @param string $comment_type
  28. * The comment type.
  29. */
  30. protected function assertEntity($comment_type) {
  31. $entity = FieldStorageConfig::load('node.' . $comment_type);
  32. $this->assertInstanceOf(FieldStorageConfig::class, $entity);
  33. $this->assertSame('node', $entity->getTargetEntityTypeId());
  34. $this->assertSame('comment', $entity->getType());
  35. $this->assertSame($comment_type, $entity->getSetting('comment_type'));
  36. }
  37. /**
  38. * Tests the migrated comment fields.
  39. */
  40. public function testMigration() {
  41. $this->assertEntity('comment_node_page');
  42. $this->assertEntity('comment_node_article');
  43. $this->assertEntity('comment_node_blog');
  44. $this->assertEntity('comment_node_book');
  45. $this->assertEntity('comment_forum');
  46. $this->assertEntity('comment_node_test_content_type');
  47. $this->assertEntity('comment_node_et');
  48. }
  49. }