X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fcomment%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd7%2FMigrateCommentTypeTest.php;fp=web%2Fcore%2Fmodules%2Fcomment%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd7%2FMigrateCommentTypeTest.php;h=60f640d297d962b90b2c660a2e6b4497a77e2927;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php b/web/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php new file mode 100644 index 000000000..60f640d29 --- /dev/null +++ b/web/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTypeTest.php @@ -0,0 +1,62 @@ +installConfig(static::$modules); + $this->executeMigrations([ + 'd7_node_type', + 'd7_comment_type', + ]); + } + + /** + * Asserts a comment type entity. + * + * @param string $id + * The entity ID. + * @param string $label + * The entity label. + */ + protected function assertEntity($id, $label) { + $entity = CommentType::load($id); + $this->assertTrue($entity instanceof CommentTypeInterface); + /** @var \Drupal\comment\CommentTypeInterface $entity */ + $this->assertIdentical($label, $entity->label()); + $this->assertIdentical('node', $entity->getTargetEntityTypeId()); + } + + /** + * Tests the migrated comment types. + */ + public function testMigration() { + $this->assertEntity('comment_node_page', 'Basic page comment'); + $this->assertEntity('comment_node_article', 'Article comment'); + $this->assertEntity('comment_node_blog', 'Blog entry comment'); + $this->assertEntity('comment_node_book', 'Book page comment'); + $this->assertEntity('comment_node_forum', 'Forum topic comment'); + $this->assertEntity('comment_node_test_content_type', 'Test content type comment'); + + $migration = $this->getMigration('d7_comment_type'); + // Validate that the source count and processed count match up. + $this->assertIdentical($migration->getSourcePlugin()->count(), $migration->getIdMap()->processedCount()); + } + +}