Version 1
[yaffs-website] / web / core / modules / node / tests / src / Kernel / Migrate / d6 / MigrateNodeBundleSettingsTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Kernel\Migrate\d6;
4
5 use Drupal\Core\Field\Entity\BaseFieldOverride;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7 use Drupal\node\Entity\Node;
8
9 /**
10  * Test migrating node settings into the base_field_bundle_override config entity.
11  *
12  * @group migrate_drupal_6
13  */
14 class MigrateNodeBundleSettingsTest 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     // Create a config entity that already exists.
30     BaseFieldOverride::create([
31       'field_name' => 'promote',
32       'entity_type' => 'node',
33       'bundle' => 'page',
34     ])->save();
35
36     $this->executeMigrations([
37       'd6_node_setting_promote',
38       'd6_node_setting_status',
39       'd6_node_setting_sticky'
40     ]);
41   }
42
43   /**
44    * Tests Drupal 6 node type settings to Drupal 8 migration.
45    */
46   public function testNodeBundleSettings() {
47     // Test settings on test_page bundle.
48     $node = Node::create(['type' => 'test_page']);
49     $this->assertIdentical(1, $node->status->value);
50     $this->assertIdentical(1, $node->promote->value);
51     $this->assertIdentical(1, $node->sticky->value);
52
53     // Test settings for test_story bundle.
54     $node = Node::create(['type' => 'test_story']);
55     $this->assertIdentical(1, $node->status->value);
56     $this->assertIdentical(1, $node->promote->value);
57     $this->assertIdentical(0, $node->sticky->value);
58
59     // Test settings for the test_event bundle.
60     $node = Node::create(['type' => 'test_event']);
61     $this->assertIdentical(0, $node->status->value);
62     $this->assertIdentical(0, $node->promote->value);
63     $this->assertIdentical(1, $node->sticky->value);
64   }
65
66 }