Commit d7840d65 authored by alexpott's avatar alexpott

Issue #2315167 by benjy: Create migrations for status/promote/sticky.

parent c78a5c29
......@@ -183,15 +183,8 @@ migrate.source.d6_node_type:
label: 'Drupal 6 node type'
mapping:
constants:
type: mapping
type: migrate_entity_constant
label: 'Constants'
mapping:
preview:
type: integer
label: 'Preview'
create_body:
type: boolean
label: 'create body'
migrate.source.d6_upload_instance:
type: migrate_source
......@@ -300,6 +293,12 @@ migrate_entity_constant:
name:
type: string
label: 'Name'
preview:
type: integer
label: 'Preview'
create_body:
type: boolean
label: 'create body'
required:
type: boolean
label: 'Required'
......
id: d6_node_setting_promote
label: Drupal 6 node type 'promote' setting
migration_groups:
- Drupal 6
source:
plugin: d6_node_type
constants:
entity_type: node
field_name: promote
process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/promote'
destination:
plugin: entity:base_field_override
id: d6_node_setting_status
label: Drupal 6 node type 'status' setting
migration_groups:
- Drupal 6
source:
plugin: d6_node_type
constants:
entity_type: node
field_name: status
process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/status'
destination:
plugin: entity:base_field_override
id: d6_node_setting_sticky
label: Drupal 6 node type 'sticky' setting
migration_groups:
- Drupal 6
source:
plugin: d6_node_type
constants:
entity_type: node
field_name: sticky
process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/sticky'
destination:
plugin: entity:base_field_override
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateNodeBundleSettingsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
/**
* Test migrating node settings into the base_field_bundle_override config entity.
*
* @group migrate_drupal
*/
class MigrateNodeBundleSettingsTest extends MigrateDrupalTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node');
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Setup the bundles.
entity_create('node_type', array('type' => 'test_page'))->save();
entity_create('node_type', array('type' => 'test_story'))->save();
entity_create('node_type', array('type' => 'test_event'))->save();
entity_create('node_type', array('type' => 'story'))->save();
// Setup the dumps.
$migration = entity_load('migration', 'd6_node_setting_promote');
$dumps = array(
$this->getDumpDirectory() . '/Drupal6NodeType.php',
);
$this->prepare($migration, $dumps);
// Run the migrations.
$executable = new MigrateExecutable($migration, $this);
$executable->import();
$migration = entity_load('migration', 'd6_node_setting_status');
$executable = new MigrateExecutable($migration, $this);
$executable->import();
$migration = entity_load('migration', 'd6_node_setting_sticky');
$executable = new MigrateExecutable($migration, $this);
$executable->import();
}
/**
* Tests Drupal 6 node type settings to Drupal 8 migration.
*/
public function testNodeBundleSettings() {
// Test settings on test_page bundle.
$node = entity_create('node', array('type' => 'test_page'));
$this->assertEqual($node->status->value, TRUE);
$this->assertEqual($node->promote->value, TRUE);
$this->assertEqual($node->sticky->value, TRUE);
// Test settings for test_story bundle.
$node = entity_create('node', array('type' => 'test_story'));
$this->assertEqual($node->status->value, TRUE);
$this->assertEqual($node->promote->value, TRUE);
$this->assertEqual($node->sticky->value, FALSE);
// Test settings for the test_event bundle.
$node = entity_create('node', array('type' => 'test_event'));
$this->assertEqual($node->status->value, FALSE);
$this->assertEqual($node->promote->value, FALSE);
$this->assertEqual($node->sticky->value, TRUE);
}
}
......@@ -14,11 +14,6 @@
/**
* Upgrade node types to node.type.*.yml.
*
* @todo https://www.drupal.org/node/2283977 adds an new config entity that
* allows customisations on the bundle level for base fields. Node status,
* promote and sticky are a case in point. We need to add the ability for
* migrate to create these fields and test it here.
*
* @group migrate_drupal
*/
class MigrateNodeTypeTest extends MigrateDrupalTestBase {
......@@ -52,6 +47,7 @@ public function testNodeType() {
// Test the test_page content type.
$node_type_page = entity_load('node_type', 'test_page');
$this->assertEqual($node_type_page->id(), 'test_page', 'Node type test_page loaded');
$this->assertEqual($node_type_page->displaySubmitted(), TRUE);
$this->assertEqual($node_type_page->isNewRevision(), FALSE);
$this->assertEqual($node_type_page->getPreviewMode(), DRUPAL_OPTIONAL);
......@@ -64,6 +60,7 @@ public function testNodeType() {
// Test the test_story content type.
$node_type_story = entity_load('node_type', 'test_story');
$this->assertEqual($node_type_story->id(), 'test_story', 'Node type test_story loaded');
$this->assertEqual($node_type_story->displaySubmitted(), TRUE);
$this->assertEqual($node_type_story->isNewRevision(), FALSE);
$this->assertEqual($node_type_story->getPreviewMode(), DRUPAL_OPTIONAL);
......@@ -76,6 +73,7 @@ public function testNodeType() {
// Test the test_event content type.
$node_type_event = entity_load('node_type', 'test_event');
$this->assertEqual($node_type_event->id(), 'test_event', 'Node type test_event loaded');
$this->assertEqual($node_type_event->displaySubmitted(), TRUE);
$this->assertEqual($node_type_event->isNewRevision(), TRUE);
$this->assertEqual($node_type_event->getPreviewMode(), DRUPAL_OPTIONAL);
......@@ -85,4 +83,5 @@ public function testNodeType() {
$instance = FieldInstanceConfig::loadByName('node', 'test_event', 'body');
$this->assertEqual($instance->getLabel(), 'Body', 'Body field was found.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment