From fb35534db53c3d2fc027548ec5a92b05ae2e4e14 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 14 Jul 2015 08:59:54 +0100
Subject: [PATCH] Issue #2409415 by phenaproxima, hosef: Variable to config:
 aggregator.settings [d7]

---
 .../d7_aggregator_settings.yml                | 25 ++++++++++
 .../src/Tests/Table/d7/Variable.php           | 23 ++++++++-
 .../d7/MigrateAggregatorSettingsTest.php      | 49 +++++++++++++++++++
 3 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 core/modules/migrate_drupal/migration_templates/d7_aggregator_settings.yml
 create mode 100644 core/modules/migrate_drupal/src/Tests/d7/MigrateAggregatorSettingsTest.php

diff --git a/core/modules/migrate_drupal/migration_templates/d7_aggregator_settings.yml b/core/modules/migrate_drupal/migration_templates/d7_aggregator_settings.yml
new file mode 100644
index 000000000000..a60d7e35d4a6
--- /dev/null
+++ b/core/modules/migrate_drupal/migration_templates/d7_aggregator_settings.yml
@@ -0,0 +1,25 @@
+id: d7_aggregator_settings
+label: Drupal 7 aggregator configuration
+migration_tags:
+  - Drupal 7
+source:
+  plugin: variable
+  variables:
+    - aggregator_fetcher
+    - aggregator_parser
+    - aggregator_processors
+    - aggregator_allowed_html_tags
+    - aggregator_teaser_length
+    - aggregator_clear
+    - aggregator_summary_items
+process:
+  fetcher: aggregator_fetcher
+  parser: aggregator_parser
+  processors: aggregator_processors
+  'items/allowed_html': aggregator_allowed_html_tags
+  'items/teaser_length': aggregator_teaser_length
+  'items/expire': aggregator_clear
+  'source/list_max': aggregator_summary_items
+destination:
+  plugin: config
+  config_name: aggregator.settings
diff --git a/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php b/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php
index f6faf11fa0f2..e3367155c9e8 100644
--- a/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php
+++ b/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php
@@ -49,6 +49,27 @@ public function load() {
     ))->values(array(
       'name' => 'admin_theme',
       'value' => 's:5:"seven";',
+    ))->values(array(
+      'name' => 'aggregator_allowed_html_tags',
+      'value' => 's:13:"<p> <div> <a>";',
+    ))->values(array(
+      'name' => 'aggregator_clear',
+      'value' => 'i:86400;',
+    ))->values(array(
+      'name' => 'aggregator_fetcher',
+      'value' => 's:10:"aggregator";',
+    ))->values(array(
+      'name' => 'aggregator_parser',
+      'value' => 's:10:"aggregator";',
+    ))->values(array(
+      'name' => 'aggregator_processors',
+      'value' => 'a:1:{i:0;s:10:"aggregator";}',
+    ))->values(array(
+      'name' => 'aggregator_summary_items',
+      'value' => 'i:6;',
+    ))->values(array(
+      'name' => 'aggregator_teaser_length',
+      'value' => 'i:500;',
     ))->values(array(
       'name' => 'allow_insecure_derivatives',
       'value' => 'b:1;',
@@ -419,4 +440,4 @@ public function load() {
   }
 
 }
-#dfc4cdd451a6575677b8c10442893d26
+#6e1892883e650f9e71e165fa6737ac4c
diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateAggregatorSettingsTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateAggregatorSettingsTest.php
new file mode 100644
index 000000000000..b01180cd4f52
--- /dev/null
+++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateAggregatorSettingsTest.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\migrate_drupal\Tests\d7\MigrateAggregatorSettingsTest.
+ */
+
+namespace Drupal\migrate_drupal\Tests\d7;
+
+use Drupal\migrate\Entity\Migration;
+use Drupal\migrate\MigrateExecutable;
+
+/**
+ * Tests migration of Aggregator's variables to configuration.
+ *
+ * @group migrate_drupal_7
+ */
+class MigrateAggregatorSettingsTest extends MigrateDrupal7TestBase {
+
+  public static $modules = ['aggregator'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(static::$modules);
+    $this->loadDumps([
+      $this->getDumpDirectory() . '/Variable.php',
+    ]);
+    $migration = Migration::load('d7_aggregator_settings');
+    (new MigrateExecutable($migration, $this))->import();
+  }
+
+  /**
+   * Tests migration of Aggregator variables to configuration.
+   */
+  public function testMigration() {
+    $config = \Drupal::config('aggregator.settings')->get();
+    $this->assertIdentical('aggregator', $config['fetcher']);
+    $this->assertIdentical('aggregator', $config['parser']);
+    $this->assertIdentical(['aggregator'], $config['processors']);
+    $this->assertIdentical('<p> <div> <a>', $config['items']['allowed_html']);
+    $this->assertIdentical(500, $config['items']['teaser_length']);
+    $this->assertIdentical(86400, $config['items']['expire']);
+    $this->assertIdentical(6, $config['source']['list_max']);
+  }
+
+}
-- 
GitLab