Commit 8095dedc authored by webchick's avatar webchick

Issue #2382703 by phenaproxima, quietone, miguelc303, benjy: Migration Files for Drupal 7 Contact

parent 203eb38f
......@@ -43,14 +43,3 @@ contact.settings:
user_default_enabled:
type: boolean
label: 'Personal contact form enabled by default'
migrate.source.d6_contact_settings:
type: migrate_source_sql
label: 'Drupal 6 contact settings'
mapping:
variables:
type: sequence
label: 'Variables'
sequence:
type: string
label: 'Variable'
# Schema for the migration source plugins.
migrate.source.contact_settings:
type: migrate_source_sql
label: 'Drupal contact settings'
mapping:
variables:
type: sequence
label: 'Variables'
sequence:
type: string
label: 'Variable'
id: d6_contact_category
id: contact_category
label: Contact category configuration
migration_tags:
- Drupal 6
- Drupal 7
source:
plugin: d6_contact_category
plugin: contact_category
process:
id:
-
......
......@@ -3,7 +3,7 @@ label: Contact configuration
migration_tags:
- Drupal 6
source:
plugin: d6_contact_settings
plugin: contact_settings
variables:
- contact_default_status
- contact_hourly_threshold
......@@ -12,11 +12,11 @@ process:
'flood/limit': contact_hourly_threshold
default_form:
plugin: migration
migration: d6_contact_category
migration: contact_category
source: default_category
destination:
plugin: config
config_name: contact.settings
migration_dependencies:
required:
- d6_contact_category
- contact_category
id: d7_contact_settings
label: Contact configuration
migration_tags:
- Drupal 7
source:
plugin: contact_settings
variables:
- contact_default_status
- contact_threshold_limit
process:
user_default_enabled: contact_default_status
'flood/limit': contact_threshold_limit
default_form:
plugin: migration
migration: contact_category
source: default_category
destination:
plugin: config
config_name: contact.settings
migration_dependencies:
required:
- contact_category
dependencies:
config:
- migrate.migration.contact_category
module:
- contact
- migrate_drupal
......@@ -2,19 +2,19 @@
/**
* @file
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactCategory.
* Contains \Drupal\contact\Plugin\migrate\source\ContactCategory.
*/
namespace Drupal\contact\Plugin\migrate\source\d6;
namespace Drupal\contact\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 contact category source from database.
* Contact category source from database.
*
* @MigrateSource(
* id = "d6_contact_category",
* id = "contact_category",
* source_provider = "contact"
* )
*/
......
......@@ -2,16 +2,16 @@
/**
* @file
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactSettings.
* Contains \Drupal\contact\Plugin\migrate\source\ContactSettings.
*/
namespace Drupal\contact\Plugin\migrate\source\d6;
namespace Drupal\contact\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\Variable;
/**
* @MigrateSource(
* id = "d6_contact_settings",
* id = "contact_settings",
* source_provider = "contact"
* )
*/
......@@ -22,11 +22,11 @@ class ContactSettings extends Variable {
*/
protected function initializeIterator() {
$default_category = $this->select('contact', 'c')
->fields('c', array('cid'))
->fields('c', ['cid'])
->condition('selected', 1)
->execute()
->fetchField();
return new \ArrayIterator(array($this->values() + array('default_category' => $default_category)));
return new \ArrayIterator([$this->values() + ['default_category' => $default_category]]);
}
}
<?php
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\MigrateContactCategoryTest.
*/
namespace Drupal\contact\Tests\Migrate;
use Drupal\contact\Entity\ContactForm;
use Drupal\contact\ContactFormInterface;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Migrate contact categories to contact.form.*.yml.
*
* @group contact_category
*/
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('contact');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('contact_category');
}
/**
* Performs various assertions on a single contact form entity.
*
* @param string $id
* The contact form ID.
* @param string $expected_label
* The expected label.
* @param string[] $expected_recipients
* The recipient e-mail addresses the form should have.
* @param string $expected_reply
* The expected reply message.
* @param integer $expected_weight
* The contact form's expected weight.
*/
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
/** @var \Drupal\contact\ContactFormInterface $entity */
$entity = ContactForm::load($id);
$this->assertTrue($entity instanceof ContactFormInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_recipients, $entity->getRecipients());
$this->assertIdentical($expected_reply, $entity->getReply());
$this->assertIdentical($expected_weight, $entity->getWeight());
}
/**
* The Drupal 6 and 7 contact categories to Drupal 8 migration.
*/
public function testContactCategory() {
$this->assertEntity('website_feedback', 'Website feedback', ['admin@example.com'], '', 0);
$this->assertEntity('some_other_category', 'Some other category', ['test@example.com'], 'Thanks for contacting us, we will reply ASAP!', 1);
$this->assertEntity('a_category_much_longer_than_thir', 'A category much longer than thirty two characters', ['fortyninechars@example.com'], '', 2);
}
}
......@@ -27,7 +27,7 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_contact_category');
$this->executeMigration('contact_category');
}
/**
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactConfigsTest.
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactSettingsTest.
*/
namespace Drupal\contact\Tests\Migrate\d6;
......@@ -15,7 +15,7 @@
*
* @group migrate_drupal_6
*/
class MigrateContactConfigsTest extends MigrateDrupal6TestBase {
class MigrateContactSettingsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
......@@ -29,7 +29,7 @@ class MigrateContactConfigsTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->executeMigrations(['d6_contact_category', 'd6_contact_settings']);
$this->executeMigrations(['contact_category', 'd6_contact_settings']);
}
/**
......
<?php
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\d7\MigrateContactSettingsTest.
*/
namespace Drupal\contact\Tests\Migrate\d7;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Tests migration of Contact settings to configuration.
*
* @group migrate_drupal_7
*/
class MigrateContactSettingsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('contact_category');
$this->executeMigration('d7_contact_settings');
}
/**
* Tests migration of Contact's variables to configuration.
*/
public function testContactSettings() {
$config = $this->config('contact.settings');
$this->assertTrue($config->get('user_default_enabled'));
$this->assertIdentical(33, $config->get('flood.limit'));
$this->assertEqual('website_testing', $config->get('default_form'));
}
}
......@@ -2,26 +2,27 @@
/**
* @file
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\d6\ContactCategoryTest.
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\ContactCategoryTest.
*/
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source\d6;
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source;
use Drupal\contact\Plugin\migrate\source\ContactCategory;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 contact category source plugin.
* Tests contact_category source plugin.
*
* @group contact
*/
class ContactCategoryTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\contact\Plugin\migrate\source\d6\ContactCategory';
const PLUGIN_CLASS = ContactCategory::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_contact_category',
'plugin' => 'contact_category',
),
);
......
......@@ -7,7 +7,7 @@
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source\d6;
use Drupal\contact\Plugin\migrate\source\d6\ContactSettings;
use Drupal\contact\Plugin\migrate\source\ContactSettings;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
......
......@@ -83,13 +83,6 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*/
protected $process;
/**
* The configuration describing the load plugins.
*
* @var array
*/
protected $load;
/**
* The cached process plugins.
*
......
......@@ -235,6 +235,12 @@ public function load() {
))->values(array(
'name' => 'contact_default_status',
'value' => 'i:1;',
))->values(array(
'name' => 'contact_threshold_limit',
'value' => 'i:33;',
))->values(array(
'name' => 'contact_threshold_window',
'value' => 'i:7200;',
))->values(array(
'name' => 'cron_key',
'value' => 's:43:"_vWFj-dRR2rNoHDwl7N__J9uZNutDcLz3w4tlPJzRAM";',
......@@ -707,4 +713,4 @@ public function load() {
}
}
#d20a0a7f31645aba285f0ce7505c80a5
#465b732a50eca616b7ccc915e28f076f
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