X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Ffile%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd6%2FMigrateUploadEntityDisplayTest.php;fp=web%2Fcore%2Fmodules%2Ffile%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd6%2FMigrateUploadEntityDisplayTest.php;h=200dc8617a334db7c48944d217ed3c0b27a86ccb;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php b/web/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php new file mode 100644 index 000000000..200dc8617 --- /dev/null +++ b/web/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php @@ -0,0 +1,69 @@ +migrateFields(); + } + + /** + * Tests Drupal 6 upload settings to Drupal 8 entity display migration. + */ + public function testUploadEntityDisplay() { + $this->executeMigration('d6_upload_entity_display'); + + $display = EntityViewDisplay::load('node.page.default'); + $component = $display->getComponent('upload'); + $this->assertIdentical('file_default', $component['type']); + + $display = EntityViewDisplay::load('node.story.default'); + $component = $display->getComponent('upload'); + $this->assertIdentical('file_default', $component['type']); + + // Assure this doesn't exist. + $display = EntityViewDisplay::load('node.article.default'); + $component = $display->getComponent('upload'); + $this->assertTrue(is_null($component)); + + $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(['page'])); + } + + /** + * Tests that entity displays are ignored appropriately. + * + * Entity displays should be ignored when they belong to node types which + * were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_upload_entity_display should skip over the "story" node type config + // because, according to the map table, it didn't occur. + $migration = $this->getMigration('d6_upload_entity_display'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]); + } + +}