Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / node / tests / src / Kernel / Migrate / d6 / MigrateNodeTypeTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Kernel\Migrate\d6;
4
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7 use Drupal\node\Entity\NodeType;
8
9 /**
10  * Upgrade node types to node.type.*.yml.
11  *
12  * @group migrate_drupal_6
13  */
14 class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['menu_ui'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->installConfig(['node']);
27     $this->executeMigration('d6_node_type');
28   }
29
30   /**
31    * Tests Drupal 6 node type to Drupal 8 migration.
32    */
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']);
42
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.');
46
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'));
52
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');
56
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']);
61
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');
65
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'));
71
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');
75
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']);
80
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.');
84
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'));
89   }
90
91 }