3 namespace Drupal\Tests\node\Kernel\Migrate\d6;
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7 use Drupal\node\Entity\NodeType;
10 * Upgrade node types to node.type.*.yml.
12 * @group migrate_drupal_6
14 class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
19 public static $modules = ['menu_ui'];
24 protected function setUp() {
26 $this->installConfig(['node']);
27 $this->executeMigration('d6_node_type');
31 * Tests Drupal 6 node type to Drupal 8 migration.
33 public function testNodeType() {
34 $id_map = $this->getMigration('d6_node_type')->getIdMap();
35 // Test the test_page content type.
36 $node_type_page = NodeType::load('test_page');
37 $this->assertIdentical('test_page', $node_type_page->id(), 'Node type test_page loaded');
38 $this->assertIdentical(TRUE, $node_type_page->displaySubmitted());
39 $this->assertIdentical(FALSE, $node_type_page->isNewRevision());
40 $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
41 $this->assertIdentical($id_map->lookupDestinationID(['test_page']), ['test_page']);
43 // Test we have a body field.
44 $field = FieldConfig::loadByName('node', 'test_page', 'body');
45 $this->assertIdentical('This is the body field label', $field->getLabel(), 'Body field was found.');
47 // Test default menus.
48 $expected_available_menus = ['navigation'];
49 $this->assertSame($expected_available_menus, $node_type_page->getThirdPartySetting('menu_ui', 'available_menus'));
50 $expected_parent = 'navigation:';
51 $this->assertSame($expected_parent, $node_type_page->getThirdPartySetting('menu_ui', 'parent'));
53 // Test the test_story content type.
54 $node_type_story = NodeType::load('test_story');
55 $this->assertIdentical('test_story', $node_type_story->id(), 'Node type test_story loaded');
57 $this->assertIdentical(TRUE, $node_type_story->displaySubmitted());
58 $this->assertIdentical(FALSE, $node_type_story->isNewRevision());
59 $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_story->getPreviewMode());
60 $this->assertIdentical($id_map->lookupDestinationID(['test_story']), ['test_story']);
62 // Test we don't have a body field.
63 $field = FieldConfig::loadByName('node', 'test_story', 'body');
64 $this->assertIdentical(NULL, $field, 'No body field found');
66 // Test default menus.
67 $expected_available_menus = ['navigation'];
68 $this->assertSame($expected_available_menus, $node_type_story->getThirdPartySetting('menu_ui', 'available_menus'));
69 $expected_parent = 'navigation:';
70 $this->assertSame($expected_parent, $node_type_story->getThirdPartySetting('menu_ui', 'parent'));
72 // Test the test_event content type.
73 $node_type_event = NodeType::load('test_event');
74 $this->assertIdentical('test_event', $node_type_event->id(), 'Node type test_event loaded');
76 $this->assertIdentical(TRUE, $node_type_event->displaySubmitted());
77 $this->assertIdentical(TRUE, $node_type_event->isNewRevision());
78 $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_event->getPreviewMode());
79 $this->assertIdentical($id_map->lookupDestinationID(['test_event']), ['test_event']);
81 // Test we have a body field.
82 $field = FieldConfig::loadByName('node', 'test_event', 'body');
83 $this->assertIdentical('Body', $field->getLabel(), 'Body field was found.');
85 $expected_available_menus = ['navigation'];
86 $this->assertSame($expected_available_menus, $node_type_event->getThirdPartySetting('menu_ui', 'available_menus'));
87 $expected_parent = 'navigation:';
88 $this->assertSame($expected_parent, $node_type_event->getThirdPartySetting('menu_ui', 'parent'));