From d1f6df12e0b9e9882126d4b4f00fd4896d2a9a23 Mon Sep 17 00:00:00 2001
From: Dries <dries@buytaert.net>
Date: Fri, 25 Jul 2014 13:22:12 -0400
Subject: [PATCH] Issue #2281443 by ultimike, TommyK: Fixed D6 Workflow
 settings -> D8 Publishing options not migrating.

---
 .../migrate.migration.d6_node_type.yml        |  6 ++--
 .../src/Plugin/migrate/source/d6/NodeType.php |  5 +--
 .../src/Tests/Dump/Drupal6NodeType.php        | 32 ++++++++++++++++---
 .../src/Tests/d6/MigrateNodeTypeTest.php      | 25 +++++++++++++--
 4 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node_type.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node_type.yml
index 4c56d6810911..609f391f3a38 100644
--- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node_type.yml
+++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node_type.yml
@@ -14,9 +14,9 @@ process:
   description: description
   help: help
   title_label: title_label
-  preview: 'constants/preview'
-  submitted: submitted
-  options: options
+  'settings/node/preview': 'constants/preview'
+  'settings/node/submitted': submitted
+  'settings/node/options': options
   create_body: has_body
   create_body_label: body_label
 destination:
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/NodeType.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/NodeType.php
index 592f8b8091f4..665cc1398f5f 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/NodeType.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/NodeType.php
@@ -103,9 +103,10 @@ public function prepareRow(Row $row) {
     $row->setSourceProperty('node_preview', $this->nodePreview);
 
     $type = $row->getSourceProperty('type');
-    $options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
+    $source_options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
+    $options = array();
     foreach (array('promote', 'sticky', 'status', 'revision') as $item) {
-      $options[$item] = isset($options[$item]);
+      $options[$item] = in_array($item, $source_options);
     }
     $row->setSourceProperty('options', $options);
     $submitted = isset($this->themeSettings['toggle_node_info_' . $type]) ? $this->themeSettings['toggle_node_info_' . $type] : FALSE;
diff --git a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6NodeType.php b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6NodeType.php
index 59736b32f696..c6e9baf74f92 100644
--- a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6NodeType.php
+++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6NodeType.php
@@ -65,6 +65,22 @@ public function load() {
         'locked' => 0,
         'orig_type' => 'story',
       ))
+      ->values(array(
+        'type' => 'test_event',
+        'name' => 'Migrate test event',
+        'module' => 'node',
+        'description' => "test event description here",
+        'help' => 'help text here',
+        'has_title' => 1,
+        'title_label' => 'Event Name',
+        'has_body' => 1,
+        'body_label' => 'Body',
+        'min_word_count' => 0,
+        'custom' => 1,
+        'modified' => 1,
+        'locked' => 0,
+        'orig_type' => 'event',
+      ))
       ->execute();
 
     $this->database->merge('node_type')
@@ -92,7 +108,7 @@ public function load() {
       'value',
     ))
     ->values(array(
-      'name' => 'node_options_migrate_test_page',
+      'name' => 'node_options_test_page',
       'value' => serialize(array(
         0 => 'status',
         1 => 'promote',
@@ -100,12 +116,19 @@ public function load() {
       )),
     ))
     ->values(array(
-      'name' => 'node_options_migrate_test_story',
+      'name' => 'node_options_test_story',
       'value' => serialize(array(
         0 => 'status',
         1 => 'promote',
       )),
     ))
+    ->values(array(
+      'name' => 'node_options_test_event',
+      'value' => serialize(array(
+        0 => 'sticky',
+        1 => 'revision',
+      )),
+    ))
     ->values(array(
       'name' => 'theme_settings',
       'value' => serialize(array(
@@ -127,8 +150,9 @@ public function load() {
         'default_favicon' => 1,
         'favicon_path' => '',
         'favicon_upload' => '',
-        'toggle_node_info_migrate_test_page' => 1,
-        'toggle_node_info_migrate_test_story' => 1,
+        'toggle_node_info_test_page' => 1,
+        'toggle_node_info_test_story' => 1,
+        'toggle_node_info_test_event' => 1,
       )),
     ))
     ->execute();
diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTypeTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTypeTest.php
index 094ca3d7199f..b497e875b9ee 100644
--- a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTypeTest.php
+++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTypeTest.php
@@ -51,7 +51,7 @@ public function testNodeType() {
       'options' => array(
         'status' => TRUE,
         'promote' => TRUE,
-        'sticky' => FALSE,
+        'sticky' => TRUE,
         'revision' => FALSE,
       ),
       'preview' => 1,
@@ -78,11 +78,32 @@ public function testNodeType() {
       'preview' => 1,
       'submitted' => TRUE,
     );
-    $this->assertEqual($node_type_page->settings['node'], $expected, 'Node type test_page settings correct.');
+    $this->assertEqual($node_type_story->settings['node'], $expected, 'Node type test_story settings correct.');
     $this->assertEqual(array('test_story'), $migration->getIdMap()->lookupDestinationID(array('test_story')));
 
     // Test we don't have a body field.
     $instance = FieldInstanceConfig::loadByName('node', 'test_story', 'body');
     $this->assertEqual($instance, NULL, 'No body field found');
+
+    // 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');
+    $expected = array(
+      'options' => array(
+        'status' => FALSE,
+        'promote' => FALSE,
+        'sticky' => TRUE,
+        'revision' => TRUE,
+      ),
+      'preview' => 1,
+      'submitted' => TRUE,
+    );
+
+    $this->assertEqual($node_type_event->settings['node'], $expected, 'Node type test_event settings correct.');
+    $this->assertEqual(array('test_event'), $migration->getIdMap()->lookupDestinationID(array('test_event')));
+
+    // Test we have a body field.
+    $instance = FieldInstanceConfig::loadByName('node', 'test_event', 'body');
+    $this->assertEqual($instance->getLabel(), 'Body', 'Body field was found.');
   }
 }
-- 
GitLab