diff --git a/core/modules/migrate/config/schema/migrate.data_types.schema.yml b/core/modules/migrate/config/schema/migrate.data_types.schema.yml index edb628a..d887785 100644 --- a/core/modules/migrate/config/schema/migrate.data_types.schema.yml +++ b/core/modules/migrate/config/schema/migrate.data_types.schema.yml @@ -14,6 +14,10 @@ migrate_destination: migrate_source: type: migrate_plugin label: 'Source' + mapping: + constants: + type: ignore + label: 'Constants' # Base schema for migrate source plugins that extend # \Drupal\migrate\Plugin\migrate\source\SqlBase. diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_field.yml new file mode 100755 index 0000000..07eada2 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_field.yml @@ -0,0 +1,42 @@ +id: d7_field +label: Drupal 7 field configuration +migration_groups: + - Drupal 7 +source: + plugin: d7_field + constants: + status: true + langcode: und +process: + entity_type: entity_type + status: 'constants/status' + langcode: 'constants/langcode' + field_name: field_name + type: + plugin: static_map + source: + - type + map: + date: datetime + datestamp: datetime + datetime: datetime + email: email + file: file + image: image + link_field: link + list_boolean: boolean + list_integer: list_integer + list_text: list_string + number_integer: integer + number_decimal: decimal + number_float: float + phone: telephone + taxonomy_term_reference: entity_reference + text: text + text_long: text_long + text_with_summary: text_with_summary + cardinality: cardinality + settings: + plugin: d7_field_settings +destination: + plugin: entity:field_storage_config diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_field_instance.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_field_instance.yml new file mode 100755 index 0000000..be30a529 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_field_instance.yml @@ -0,0 +1,32 @@ +id: d7_field_instance +migration_groups: + - Drupal 7 +source: + plugin: d7_field_instance + constants: + status: true +process: + entity_type: entity_type + field_name: field_name + bundle: bundle + label: label + description: description + required: required + status: 'constants/status' + settings: + plugin: d7_field_instance_settings + source: + - instance_settings + - widget_settings + + default_value_function: '' + default_value: + plugin: d7_field_instance_defaults + source: + - default_value + - widget_settings +destination: + plugin: entity:field_config +migration_dependencies: + required: + - d7_field diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_file.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_file.yml new file mode 100755 index 0000000..17757f7 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_file.yml @@ -0,0 +1,20 @@ +# Every migration that saves into {file_managed} must have the d7_file +# migration as an optional dependency to ensure d7_file runs first. +id: d7_file +label: Drupal 7 files +migration_groups: + - Drupal 7 +source: + plugin: d7_file +process: + fid: fid + filename: filename + uid: uid + uri: uri + filemime: filemime + filesize: filesize + status: status + created: timestamp + changed: timestamp +destination: + plugin: entity:file diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_image_settings.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_image_settings.yml new file mode 100755 index 0000000..67f82b0 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_image_settings.yml @@ -0,0 +1,14 @@ +id: d7_image_settings +migration_groups: + - Drupal 7 +source: + plugin: variable + variables: + - allow_insecure_derivatives + - suppress_itok_output +process: + suppress_itok_output: suppress_itok_output + allow_insecure_derivatives: allow_insecure_derivatives +destination: + plugin: config + config_name: image.settings diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_system_authorize.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_system_authorize.yml new file mode 100755 index 0000000..4713620 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_system_authorize.yml @@ -0,0 +1,12 @@ +id: d7_system_authorize +migration_groups: + - Drupal 7 +source: + plugin: variable + variables: + - authorize_filetransfer_default +process: + filetransfer_default: authorize_filetransfer_default +destination: + plugin: config + config_name: system.authorize diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_term.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_term.yml new file mode 100755 index 0000000..721dc34 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_term.yml @@ -0,0 +1,28 @@ +id: d7_taxonomy_term +label: Drupal 7 taxonomy terms +migration_groups: + - Drupal 7 +source: + plugin: d7_taxonomy_term +process: + tid: tid + vid: + plugin: migration + migration: d7_taxonomy_vocabulary + source: vid + name: name + description: description + weight: weight + parent: + - + plugin: skip_process_on_empty + source: parent + - + plugin: migration + migration: d7_taxonomy_term + changed: timestamp +destination: + plugin: entity:taxonomy_term +migration_dependencies: + required: + - d7_taxonomy_vocabulary diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_vocabulary.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_vocabulary.yml new file mode 100755 index 0000000..1b42ae0 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_taxonomy_vocabulary.yml @@ -0,0 +1,24 @@ +id: d7_taxonomy_vocabulary +label: Drupal 7 taxonomy vocabularies +migration_groups: + - Drupal 7 +source: + plugin: d7_taxonomy_vocabulary +process: + vid: + - + plugin: machine_name + source: machine_name + - + plugin: dedupe_entity + entity_type: taxonomy_vocabulary + field: vid + length: 32 + label: name + name: name + description: description + hierarchy: hierarchy + module: module + weight: weight +destination: + plugin: entity:taxonomy_vocabulary diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_user.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_user.yml new file mode 100755 index 0000000..5b87dc1 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_user.yml @@ -0,0 +1,34 @@ +id: d7_user +migration_groups: + - Drupal 7 +source: + plugin: d7_user +destination: + plugin: entity:user +process: + uid: uid + name: name + pass: pass + mail: mail + status: status + signature: signature + # TODO: whe the d7 text format migration is written, uncomment the following. +# signature_format: +# plugin: migration +# migration: d6_filter_format +# source: signature_format +# no_stub: 1 + created: created + changed: changed + access: access + login: login + timezone: timezone + langcode: language + preferred_langcode: language + preferred_admin_langcode: language + init: init + # d7 user roles migration is not written yet. +# roles: +# plugin: migration +# migration: d7_user_role +# source: roles \ No newline at end of file diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d7_user_flood.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d7_user_flood.yml new file mode 100755 index 0000000..ca82a23 --- /dev/null +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d7_user_flood.yml @@ -0,0 +1,20 @@ +id: d7_user_flood +migration_groups: + - Drupal 7 +source: + plugin: variable + variables: + - user_failed_login_identifier_uid_only + - user_failed_login_ip_limit + - user_failed_login_ip_window + - user_failed_login_user_window + - user_failed_login_user_limit +process: + uid_only: user_failed_login_identifier_uid_only + ip_limit: user_failed_login_ip_limit + ip_window: user_failed_login_ip_window + user_limit: user_failed_login_user_limit + user_window: user_failed_login_user_window +destination: + plugin: config + config_name: user.flood diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php b/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php new file mode 100755 index 0000000..38121d1 --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php @@ -0,0 +1,42 @@ + $instance_settings['default_image'], + 'alt' => '', + 'title' => '', + 'width' => NULL, + 'height' => NULL, + 'uuid' => '', + ); + break; + + default: + $settings = $instance_settings; + } + + // Remove 'user_register_form'. + // @see https://drupal.org/node/2049485' + unset($settings['user_register_form']); + + return $settings; + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldSettings.php b/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldSettings.php new file mode 100755 index 0000000..6aae9bb --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d7/FieldSettings.php @@ -0,0 +1,38 @@ +getSourceProperty('settings'); + + if ($row->getSourceProperty('type') == 'image' && !is_array($value['default_image'])) { + $value['default_image'] = array( + 'uuid' => '', + ); + } + + return $value; + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Field.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Field.php new file mode 100755 index 0000000..edc6b6f --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Field.php @@ -0,0 +1,99 @@ +select('field_config', 'fc') + ->fields('fc', array( + 'field_name', + 'type', + 'module', + 'storage_type', + 'storage_module', + 'locked', + 'data', + 'cardinality', + 'translatable', + )) + ->fields('fci', array( + 'entity_type', + )) + ->condition('fc.active', 1) + ->condition('fc.deleted', 0) + ->condition('fc.storage_active', 1); + $query->join('field_config_instance', 'fci', 'fc.id = fci.field_id'); + $query->orderBy('fc.field_name'); + + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'field_name' => $this->t('The name of this field.'), + 'type' => $this->t('The type of this field.'), + 'module' => $this->t('The module that implements the field type.') , + 'storage' => $this->t('The field stoerage.'), + 'locked' => $this->t( 'Locked'), + 'cardinality' => $this->t('Cardinality'), + 'translatable' => $this->t('translatable'), + ); + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row, $keep = TRUE) { + // The logic is from field_read_fields() in Drupal 7. + $field = unserialize($row->getSourceProperty('data')); + $field['field_name'] = $row->getSourceProperty('field_name'); + $field['type'] = $row->getSourceProperty('type'); + $field['module'] = $row->getSourceProperty('module'); + $field['storage']['type'] = $row->getSourceProperty('storage_type'); + $field['storage']['module'] = $row->getSourceProperty('storage_module'); + $field['locked'] = $row->getSourceProperty('locked'); + $field['cardinality'] = $row->getSourceProperty('cardinality'); + $field['translatable'] = $row->getSourceProperty('translatable'); + foreach ($field as $key => $data) { + $row->setSourceProperty($key, $data); + } + return parent::prepareRow($row); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['field_name']['type'] = 'string'; + $ids['field_name']['alias'] = 'fc'; + $ids['entity_type']['type'] = 'string'; + $ids['entity_type']['alias'] = 'fci'; + return $ids; + } +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldInstance.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldInstance.php new file mode 100755 index 0000000..0eab585 --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldInstance.php @@ -0,0 +1,107 @@ +select('field_config_instance', 'fci') + ->fields('fci', array('field_name', 'entity_type', 'bundle', 'data')) + ->condition('fci.deleted', 0) + ->condition('fc.active', 1) + ->condition('fc.deleted', 0) + ->condition('fc.storage_active', 1); + $query->innerJoin('field_config', 'fc', 'fci.field_id = fc.id'); + + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'field_name' => $this->t('The machine name of field.'), + 'entity_type' => $this->t('The entity type.'), + 'bundle' => $this->t('The entity bundle.'), + 'default_value' => $this->t('Default value'), + 'instance_settings' => $this->t('Field instance settings.'), + 'widget_settings' => $this->t('Widget settings.'), + 'display_settings' => $this->t('Display settings.'), + + /* + 'weight' => $this->t('Weight.'), + 'label' => $this->t('A name to show.'), + 'widget_type' => $this->t('Widget type.'), + 'description' => $this->t('A description of field.'), + 'widget_module' => $this->t('Module that implements widget.'), + 'widget_active' => $this->t('Status of widget'), + 'module' => $this->t('The module that provides the field.'), + */ + + ); + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row, $keep = TRUE) { + $data = unserialize($row->getSourceProperty('data')); + + $row->setSourceProperty('label', $data['label']); + $row->setSourceProperty('description', $data['description']); + $row->setSourceProperty('required', $data['required']); + + $default_value = !empty($data['default_value']) ? $data['default_value'] : array(); + if ($data['widget']['type'] == 'email_textfield' && $default_value) { + $default_value[0]['value'] = $default_value[0]['email']; + unset($default_value[0]['email']); + } + $row->setSourceProperty('default_value', $default_value); + + // Settings. + $row->setSourceProperty('instance_settings', $data['settings']); + $row->setSourceProperty('widget_settings', $data['widget']); + $row->setSourceProperty('display_settings', $data['display']); + + return parent::prepareRow($row); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + return array( + 'entity_type' => array( + 'type' => 'string', + 'alias' => 'fci', + ), + 'bundle' => array( + 'type' => 'string', + 'alias' => 'fci', + ), + 'field_name' => array( + 'type' => 'string', + 'alias' => 'fci', + ), + ); + } +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/File.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/File.php new file mode 100755 index 0000000..e5fd782 --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/File.php @@ -0,0 +1,90 @@ +select('file_managed', 'f')->fields('f', array( + 'fid', + 'uid', + 'filename', + 'uri', + 'filemime', + 'filesize', + 'status', + 'timestamp', + 'type' + )); + return $query; + } + + + /** + * {@inheritdoc} + */ + protected function runQuery() { + $conf_path = isset($this->configuration['conf_path']) ? $this->configuration['conf_path'] : 'sites/default'; + $this->filePath = $this->variableGet('file_directory_path', $conf_path . '/files') . '/'; + + // FILE_DOWNLOADS_PUBLIC == 1 and FILE_DOWNLOADS_PRIVATE == 2. + $this->isPublic = $this->variableGet('file_downloads', 1) == 1; + return parent::runQuery(); + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'fid' => $this->t('File ID'), + 'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'), + 'filename' => $this->t('File name'), + 'uri' => $this->t('File URI'), + 'filemime' => $this->t('File Mime Type'), + 'status' => $this->t('The published status of a file.'), + 'created' => $this->t('The time that the file was added.'), + 'changed' => $this->t('The time that the file was last changed.'), + ); + } + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['fid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Term.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Term.php new file mode 100755 index 0000000..157ec5b --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Term.php @@ -0,0 +1,78 @@ +select('taxonomy_term_data', 'td') + ->fields('td', array('tid', 'vid', 'name', 'description', 'weight', 'format')) + // This works, but we cannot test that, because there is no support for + // distinct() in FakeSelect, yet. + ->distinct(); + if (isset($this->configuration['vocabulary'])) { + $query->condition('vid', $this->configuration['vocabulary'], 'IN'); + } + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'tid' => $this->t('The term ID.'), + 'vid' => $this->t('Existing term VID'), + 'name' => $this->t('The name of the term.'), + 'description' => $this->t('The term description.'), + 'weight' => $this->t('Weight'), + 'parent' => $this->t("The Drupal term IDs of the term's parents."), + ); + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + // Find parents for this row. + $parents = $this->select('taxonomy_term_hierarchy', 'th') + ->fields('th', array('parent', 'tid')) + ->condition('tid', $row->getSourceProperty('tid')) + ->execute() + ->fetchCol(); + $row->setSourceProperty('parent', $parents); + return parent::prepareRow($row); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['tid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/User.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/User.php new file mode 100755 index 0000000..c2801f6 --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/User.php @@ -0,0 +1,94 @@ +select('users', 'u') + ->fields('u', array_keys($this->baseFields())) + ->condition('uid', 0, '>') + ->orderBy('uid'); + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = $this->baseFields(); + return $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + return array( + 'uid' => array( + 'type' => 'integer', + 'alias' => 'u', + ), + ); + } + + /** + * Returns the user base fields to be migrated. + * + * @return array + * Associative array having field name as key and description as value. + */ + protected function baseFields() { + $fields = array( + 'uid' => $this->t('User ID'), + 'name' => $this->t('Username'), + 'pass' => $this->t('Password'), + 'mail' => $this->t('Email address'), + 'signature' => $this->t('Signature'), + 'signature_format' => $this->t('Signature format'), + 'created' => $this->t('Registered timestamp'), + 'access' => $this->t('Last access timestamp'), + 'login' => $this->t('Last login timestamp'), + 'status' => $this->t('Status'), + 'timezone' => $this->t('Timezone'), + 'language' => $this->t('Language'), + 'picture' => $this->t('Picture'), + 'init' => $this->t('Init'), + ); + return $fields; + +} + + /** + * {@inheritdoc} + */ + public function bundleMigrationRequired() { + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function entityTypeId() { + return 'user'; + } + +} \ No newline at end of file diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Vocabulary.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Vocabulary.php new file mode 100755 index 0000000..929009e --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/Vocabulary.php @@ -0,0 +1,66 @@ +select('taxonomy_vocabulary', 'v') + ->fields('v', array( + 'vid', + 'name', + 'description', + 'hierarchy', + 'module', + 'weight', + 'machine_name' + )); + $query->condition('vid', array(5,6), 'NOT IN'); + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'vid' => $this->t('The vocabulary ID.'), + 'name' => $this->t('The name of the vocabulary.'), + 'description' => $this->t('The description of the vocabulary.'), + 'help' => $this->t('Help text to display for the vocabulary.'), + 'relations' => $this->t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'), + 'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'), + 'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'), + 'parents' => $this->t("The Drupal term IDs of the term's parents."), + 'node_types' => $this->t('The names of the node types the vocabulary may be used with.'), + ); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['vid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php b/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php new file mode 100644 index 0000000..d5bfc9e --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php @@ -0,0 +1,469 @@ +createTable("variable", array( + 'primary key' => array( + 'name', + ), + 'fields' => array( + 'name' => array( + 'type' => 'varchar', + 'not null' => TRUE, + 'length' => '128', + 'default' => '', + ), + 'value' => array( + 'type' => 'blob', + 'not null' => TRUE, + 'length' => 100, + ), + ), + )); + $this->database->insert("variable")->fields(array( + 'name', + 'value', + )) + ->values(array( + 'name' => 'additional_settings__active_tab_test_content_type', + 'value' => 's:15:"edit-submission";', + ))->values(array( + 'name' => 'admin_theme', + 'value' => 's:5:"seven";', + ))->values(array( + 'name' => 'allow_insecure_derivatives', + 'value' => 'b:1;', + ))->values(array( + 'name' => 'anonymous', + 'value' => 's:9:"Anonymous";', + ))->values(array( + 'name' => 'authorize_filetransfer_default', + 'value' => 's:3:"ftp";', + ))->values(array( + 'name' => 'block_cache', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'book_allowed_types', + 'value' => 'a:1:{i:0;s:4:"book";}', + ))->values(array( + 'name' => 'book_child_type', + 'value' => 's:4:"book";', + ))->values(array( + 'name' => 'cache', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_block', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_field', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_filter', + 'value' => 'i:1432305936;', + ))->values(array( + 'name' => 'cache_flush_cache_form', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_image', + 'value' => 'i:1432305936;', + ))->values(array( + 'name' => 'cache_flush_cache_menu', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_page', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_flush_cache_path', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'cache_lifetime', + 'value' => 's:3:"300";', + ))->values(array( + 'name' => 'clean_url', + 'value' => 's:1:"1";', + ))->values(array( + 'name' => 'comment_anonymous_test_content_type', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'comment_default_mode_test_content_type', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'comment_default_per_page_test_content_type', + 'value' => 's:2:"30";', + ))->values(array( + 'name' => 'comment_form_location_test_content_type', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'comment_page', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'comment_preview_test_content_type', + 'value' => 's:1:"1";', + ))->values(array( + 'name' => 'comment_subject_field_test_content_type', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'comment_test_content_type', + 'value' => 's:1:"2";', + ))->values(array( + 'name' => 'contact_default_status', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'cron_key', + 'value' => 's:43:"_vWFj-dRR2rNoHDwl7N__J9uZNutDcLz3w4tlPJzRAM";', + ))->values(array( + 'name' => 'cron_last', + 'value' => 'i:1432305936;', + ))->values(array( + 'name' => 'css_js_query_string', + 'value' => 's:6:"nihmmw";', + ))->values(array( + 'name' => 'ctools_last_cron', + 'value' => 'i:1421720834;', + ))->values(array( + 'name' => 'dashboard_stashed_blocks', + 'value' => 'a:5:{i:0;a:3:{s:6:"module";s:4:"node";s:5:"delta";s:6:"recent";s:6:"region";s:14:"dashboard_main";}i:1;a:3:{s:6:"module";s:4:"user";s:5:"delta";s:3:"new";s:6:"region";s:17:"dashboard_sidebar";}i:2;a:3:{s:6:"module";s:6:"search";s:5:"delta";s:4:"form";s:6:"region";s:17:"dashboard_sidebar";}i:3;a:3:{s:6:"module";s:7:"comment";s:5:"delta";s:6:"recent";s:6:"region";s:18:"dashboard_inactive";}i:4;a:3:{s:6:"module";s:4:"user";s:5:"delta";s:6:"online";s:6:"region";s:18:"dashboard_inactive";}}', + ))->values(array( + 'name' => 'date_api_version', + 'value' => 's:3:"7.2";', + ))->values(array( + 'name' => 'date_default_timezone', + 'value' => 's:15:"America/Chicago";', + ))->values(array( + 'name' => 'default_nodes_main', + 'value' => 's:2:"10";', + ))->values(array( + 'name' => 'drupal_css_cache_files', + 'value' => 'a:10:{s:64:"823ba1006db72809515d2221cd02ec1075d7b49b0c07f49307b3a7930bfdd9e4";s:64:"public://css/css_xE-rWrJf-fncB6ztZfd2huxqgxu4WO-qwma6Xer30m4.css";s:64:"592db66916e1dd3416cbe95bcb34a5a68775eb0b7cf95e4c858671de35290cc9";s:64:"public://css/css_LS9OUalDR9-d_lCAvF3yUWjNU6yF8ZBm84jEPRvoyuQ.css";s:64:"039ba69b25efd672767c5ee21b686a2cdaa496c5fb210693b88f81cc556db518";s:64:"public://css/css_ELXvY8pQ9Dhp7LiF1Gra7jv5X_cMGOmgGfJ6go69M0w.css";s:64:"fe9fca5a618e55058e69458a65b2edb4e958c16c13e1d1526c4dc0c0e782b483";s:64:"public://css/css_WWafHiT44xXp69Ucog34hgXKsZRScJzl3S17Xg7evtM.css";s:64:"ebb3f433ad4107b1ac31e9d7de0f9a5d399040e9f82b6364211dcfaadea158c0";s:64:"public://css/css_Nv0ct-zkzztuah_LbaPFF8ZkdSEk-LxBtTWMm9mN_F8.css";s:64:"568f3bca87830de88c7b44e71808ac7f33f4cdf273ed3bf3d2532bd48f084b06";s:64:"public://css/css_NRg0AX3iY_x0OX3_WzcWp90JnwurHRvZn6i75GL0rRI.css";s:64:"586e4d641f74d0fbdea2ecffe62294e983c5961df8d0128aab1c561505f6b35a";s:64:"public://css/css_2THG1eGiBIizsWFeexsNe1iDifJ00QRS9uSd03rY9co.css";s:64:"cb9f93e666a396bb3eb14c5fd16f7ebd1cdd0067733eb0a2ab1b294b6f14f76f";s:64:"public://css/css_1kF33EODTO5gDyEbdpAfYzMKbjG3ottD1s5np0BNI8U.css";s:64:"35337ea541d4968f58917d83eaa9e495d5a38bb0aaf23bc714650d3c71fc275a";s:64:"public://css/css_LJ87GFKz9ZFt2bWZ4pMV8e2o8w_790Mbwcd7C-RKri0.css";s:64:"032d72e2b3124645b11e59c23005327dc2b450af6aaa6bf3cad34a6a65a9d774";s:64:"public://css/css_ZDWl28hdmeinIcKg-HMrN6uKD0nTMld5NlXLmm5MH2U.css";}', + ))->values(array( + 'name' => 'drupal_http_request_fails', + 'value' => 'b:0;', + ))->values(array( + 'name' => 'drupal_private_key', + 'value' => 's:43:"9eRJWxrMwQ5CufYJjXBZbPGz_t8vPIYRQr18PamdKmM";', + ))->values(array( + 'name' => 'email__active_tab', + 'value' => 's:25:"edit-email-password-reset";', + ))->values(array( + 'name' => 'field_bundle_settings_comment__comment_node_test_content_type', + 'value' => 'a:2:{s:10:"view_modes";a:0:{}s:12:"extra_fields";a:2:{s:4:"form";a:2:{s:6:"author";a:1:{s:6:"weight";s:2:"-2";}s:7:"subject";a:1:{s:6:"weight";s:2:"-1";}}s:7:"display";a:0:{}}}', + ))->values(array( + 'name' => 'field_bundle_settings_node__test_content_type', + 'value' => 'a:2:{s:10:"view_modes";a:6:{s:6:"teaser";a:1:{s:15:"custom_settings";b:1;}s:4:"full";a:1:{s:15:"custom_settings";b:0;}s:3:"rss";a:1:{s:15:"custom_settings";b:0;}s:12:"search_index";a:1:{s:15:"custom_settings";b:0;}s:13:"search_result";a:1:{s:15:"custom_settings";b:0;}s:5:"print";a:1:{s:15:"custom_settings";b:0;}}s:12:"extra_fields";a:2:{s:4:"form";a:1:{s:5:"title";a:1:{s:6:"weight";s:1:"0";}}s:7:"display";a:0:{}}}', + ))->values(array( + 'name' => 'field_bundle_settings_user__user', + 'value' => 'a:2:{s:10:"view_modes";a:0:{}s:12:"extra_fields";a:2:{s:4:"form";a:2:{s:7:"account";a:1:{s:6:"weight";s:3:"-10";}s:8:"timezone";a:1:{s:6:"weight";s:1:"6";}}s:7:"display";a:0:{}}}', + ))->values(array( + 'name' => 'file_temporary_path', + 'value' => 's:4:"/tmp";', + ))->values(array( + 'name' => 'filter_fallback_format', + 'value' => 's:10:"plain_text";', + ))->values(array( + 'name' => 'forum_containers', + 'value' => 'a:1:{i:0;s:1:"6";}', + ))->values(array( + 'name' => 'forum_nav_vocabulary', + 'value' => 's:1:"2";', + ))->values(array( + 'name' => 'install_profile', + 'value' => 's:8:"standard";', + ))->values(array( + 'name' => 'install_task', + 'value' => 's:4:"done";', + ))->values(array( + 'name' => 'install_time', + 'value' => 'i:1421694923;', + ))->values(array( + 'name' => 'javascript_parsed', + 'value' => 'a:13:{i:0;s:14:"misc/drupal.js";i:1;s:14:"misc/jquery.js";i:2;s:19:"misc/jquery.once.js";i:3;s:12:"misc/form.js";i:4;s:21:"misc/jquery.cookie.js";i:5;s:26:"modules/toolbar/toolbar.js";i:6;s:19:"misc/tableheader.js";i:7;s:16:"misc/collapse.js";i:8;s:32:"modules/contextual/contextual.js";i:9;s:20:"modules/user/user.js";i:10;s:16:"misc/textarea.js";i:11;s:14:"misc/states.js";i:12;s:21:"misc/vertical-tabs.js";}', + ))->values(array( + 'name' => 'language_content_type_test_content_type', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'language_negotiation_language', + 'value' => 'a:0:{}', + ))->values(array( + 'name' => 'language_negotiation_language_content', + 'value' => 'a:1:{s:16:"locale-interface";a:2:{s:9:"callbacks";a:1:{s:8:"language";s:30:"locale_language_from_interface";}s:4:"file";s:19:"includes/locale.inc";}}', + ))->values(array( + 'name' => 'language_negotiation_language_url', + 'value' => 'a:2:{s:10:"locale-url";a:2:{s:9:"callbacks";a:3:{s:8:"language";s:24:"locale_language_from_url";s:8:"switcher";s:28:"locale_language_switcher_url";s:11:"url_rewrite";s:31:"locale_language_url_rewrite_url";}s:4:"file";s:19:"includes/locale.inc";}s:19:"locale-url-fallback";a:2:{s:9:"callbacks";a:1:{s:8:"language";s:28:"locale_language_url_fallback";}s:4:"file";s:19:"includes/locale.inc";}}', + ))->values(array( + 'name' => 'language_types', + 'value' => 'a:3:{s:8:"language";b:1;s:16:"language_content";b:0;s:12:"language_url";b:0;}', + ))->values(array( + 'name' => 'maintenance_mode', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'maintenance_mode_message', + 'value' => 's:42:"This is a custom maintenance mode message.";', + ))->values(array( + 'name' => 'menu_default_active_menus', + 'value' => 'a:2:{i:0;s:9:"main-menu";i:1;s:10:"navigation";}', + ))->values(array( + 'name' => 'menu_expanded', + 'value' => 'a:0:{}', + ))->values(array( + 'name' => 'menu_masks', + 'value' => 'a:36:{i:0;i:501;i:1;i:493;i:2;i:250;i:3;i:247;i:4;i:246;i:5;i:245;i:6;i:126;i:7;i:125;i:8;i:123;i:9;i:122;i:10;i:121;i:11;i:117;i:12;i:63;i:13;i:62;i:14;i:61;i:15;i:60;i:16;i:59;i:17;i:58;i:18;i:44;i:19;i:31;i:20;i:30;i:21;i:29;i:22;i:24;i:23;i:21;i:24;i:15;i:25;i:14;i:26;i:13;i:27;i:12;i:28;i:11;i:29;i:8;i:30;i:7;i:31;i:6;i:32;i:5;i:33;i:3;i:34;i:2;i:35;i:1;}', + ))->values(array( + 'name' => 'menu_options_test_content_type', + 'value' => 'a:4:{i:0;s:9:"main-menu";i:1;s:10:"management";i:2;s:10:"navigation";i:3;s:9:"user-menu";}', + ))->values(array( + 'name' => 'menu_parent_test_content_type', + 'value' => 's:11:"main-menu:0";', + ))->values(array( + 'name' => 'minimum_word_size', + 'value' => 's:1:"4";', + ))->values(array( + 'name' => 'node_admin_theme', + 'value' => 's:1:"1";', + ))->values(array( + 'name' => 'node_cron_last', + 'value' => 's:10:"1421727515";', + ))->values(array( + 'name' => 'node_options_book', + 'value' => 'a:1:{i:0;s:6:"status";}', + ))->values(array( + 'name' => 'node_options_forum', + 'value' => 'a:1:{i:0;s:6:"status";}', + ))->values(array( + 'name' => 'node_options_page', + 'value' => 'a:1:{i:0;s:6:"status";}', + ))->values(array( + 'name' => 'node_options_test_content_type', + 'value' => 'a:2:{i:0;s:6:"status";i:1;s:7:"promote";}', + ))->values(array( + 'name' => 'node_preview_test_content_type', + 'value' => 's:1:"1";', + ))->values(array( + 'name' => 'node_rank_comments', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'node_rank_promote', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'node_rank_relevance', + 'value' => 's:1:"2";', + ))->values(array( + 'name' => 'node_rank_sticky', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'node_rank_views', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'node_submitted_page', + 'value' => 'b:0;', + ))->values(array( + 'name' => 'node_submitted_test_content_type', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'overlap_cjk', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'page_cache_maximum_age', + 'value' => 's:1:"0";', + ))->values(array( + 'name' => 'page_compression', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'path_alias_whitelist', + 'value' => 'a:1:{s:8:"taxonomy";b:1;}', + ))->values(array( + 'name' => 'preprocess_css', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'preprocess_js', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'save_continue_test_content_type', + 'value' => 's:19:"Save and add fields";', + ))->values(array( + 'name' => 'search_active_modules', + 'value' => 'a:2:{s:4:"node";s:4:"node";s:4:"user";s:4:"user";}', + ))->values(array( + 'name' => 'search_cron_limit', + 'value' => 's:3:"100";', + ))->values(array( + 'name' => 'search_default_module', + 'value' => 's:4:"node";', + ))->values(array( + 'name' => 'site_403', + 'value' => 's:4:"node";', + ))->values(array( + 'name' => 'site_404', + 'value' => 's:4:"node";', + ))->values(array( + 'name' => 'site_default_country', + 'value' => 's:2:"US";', + ))->values(array( + 'name' => 'site_frontpage', + 'value' => 's:4:"node";', + ))->values(array( + 'name' => 'site_mail', + 'value' => 's:23:"joseph@flattandsons.com";', + ))->values(array( + 'name' => 'site_name', + 'value' => 's:13:"The Site Name";', + ))->values(array( + 'name' => 'site_slogan', + 'value' => 's:10:"The Slogan";', + ))->values(array( + 'name' => 'statistics_count_content_views', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'statistics_count_content_views_ajax', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'statistics_day_timestamp', + 'value' => 'i:1432232600;', + ))->values(array( + 'name' => 'statistics_enable_access_log', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'statistics_flush_accesslog_timer', + 'value' => 's:4:"3600";', + ))->values(array( + 'name' => 'suppress_itok_output', + 'value' => 'b:1;', + ))->values(array( + 'name' => 'theme_default', + 'value' => 's:6:"bartik";', + ))->values(array( + 'name' => 'update_last_check', + 'value' => 'i:1432232604;', + ))->values(array( + 'name' => 'user_admin_role', + 'value' => 's:1:"3";', + ))->values(array( + 'name' => 'user_cancel_method', + 'value' => 's:17:"user_cancel_block";', + ))->values(array( + 'name' => 'user_email_verification', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'user_failed_login_identifier_uid_only', + 'value' => 'b:1;', + ))->values(array( + 'name' => 'user_failed_login_ip_limit', + 'value' => 'i:30;', + ))->values(array( + 'name' => 'user_failed_login_ip_window', + 'value' => 'i:7200;', + ))->values(array( + 'name' => 'user_failed_login_user_limit', + 'value' => 'i:22;', + ))->values(array( + 'name' => 'user_failed_login_user_window', + 'value' => 'i:86400;', + ))->values(array( + 'name' => 'user_mail_cancel_confirm_body', + 'value' => "s:381:\"[user:name],\r\n\r\nA request to cancel your account has been made at [site:name].\r\n\r\nYou may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser:\r\n\r\n[user:cancel-url]\r\n\r\nNOTE: The cancellation of your account is not reversible.\r\n\r\nThis link expires in one day and nothing will happen if it is not used.\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_cancel_confirm_subject', + 'value' => 's:59:"Account cancellation request for [user:name] at [site:name]";', + ))->values(array( + 'name' => 'user_mail_password_reset_body', + 'value' => "s:407:\"[user:name],\r\n\r\nA request to reset the password for your account has been made at [site:name].\r\n\r\nYou may now log in by clicking this link or copying and pasting it to your browser:\r\n\r\n[user:one-time-login-url]\r\n\r\nThis link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_password_reset_subject', + 'value' => 's:60:"Replacement login information for [user:name] at [site:name]";', + ))->values(array( + 'name' => 'user_mail_register_admin_created_body', + 'value' => "s:476:\"[user:name],\r\n\r\nA site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:\r\n\r\n[user:one-time-login-url]\r\n\r\nThis link can only be used once to log in and will lead you to a page where you can set your password.\r\n\r\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\r\n\r\nusername: [user:name]\r\npassword: Your password\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_register_admin_created_subject', + 'value' => 's:58:"An administrator created an account for you at [site:name]";', + ))->values(array( + 'name' => 'user_mail_register_no_approval_required_body', + 'value' => "s:450:\"[user:name],\r\n\r\nThank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser:\r\n\r\n[user:one-time-login-url]\r\n\r\nThis link can only be used once to log in and will lead you to a page where you can set your password.\r\n\r\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\r\n\r\nusername: [user:name]\r\npassword: Your password\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_register_no_approval_required_subject', + 'value' => 's:46:"Account details for [user:name] at [site:name]";', + ))->values(array( + 'name' => 'user_mail_register_pending_approval_body', + 'value' => "s:287:\"[user:name],\r\n\r\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.\r\n\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_register_pending_approval_subject', + 'value' => 's:71:"Account details for [user:name] at [site:name] (pending admin approval)";', + ))->values(array( + 'name' => 'user_mail_status_activated_body', + 'value' => "s:461:\"[user:name],\r\n\r\nYour account at [site:name] has been activated.\r\n\r\nYou may now log in by clicking this link or copying and pasting it into your browser:\r\n\r\n[user:one-time-login-url]\r\n\r\nThis link can only be used once to log in and will lead you to a page where you can set your password.\r\n\r\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\r\n\r\nusername: [user:name]\r\npassword: Your password\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_status_activated_notify', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'user_mail_status_activated_subject', + 'value' => 's:57:"Account details for [user:name] at [site:name] (approved)";', + ))->values(array( + 'name' => 'user_mail_status_blocked_body', + 'value' => "s:85:\"[user:name],\r\n\r\nYour account on [site:name] has been blocked.\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_status_blocked_notify', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'user_mail_status_blocked_subject', + 'value' => 's:56:"Account details for [user:name] at [site:name] (blocked)";', + ))->values(array( + 'name' => 'user_mail_status_canceled_body', + 'value' => "s:86:\"[user:name],\r\n\r\nYour account on [site:name] has been canceled.\r\n\r\n-- [site:name] team\";", + ))->values(array( + 'name' => 'user_mail_status_canceled_notify', + 'value' => 'i:0;', + ))->values(array( + 'name' => 'user_mail_status_canceled_subject', + 'value' => 's:57:"Account details for [user:name] at [site:name] (canceled)";', + ))->values(array( + 'name' => 'user_pictures', + 'value' => 'i:1;', + ))->values(array( + 'name' => 'user_picture_default', + 'value' => 's:0:"";', + ))->values(array( + 'name' => 'user_picture_dimensions', + 'value' => 's:9:"1024x1024";', + ))->values(array( + 'name' => 'user_picture_file_size', + 'value' => 's:3:"800";', + ))->values(array( + 'name' => 'user_picture_guidelines', + 'value' => 's:0:"";', + ))->values(array( + 'name' => 'user_picture_path', + 'value' => 's:8:"pictures";', + ))->values(array( + 'name' => 'user_picture_style', + 'value' => 's:9:"thumbnail";', + ))->values(array( + 'name' => 'user_register', + 'value' => 's:1:"2";', + ))->values(array( + 'name' => 'user_signatures', + 'value' => 'i:0;', + ))->execute(); + } + +} +#de614df0c57e9838130a3de74c7030e9 diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php new file mode 100644 index 0000000..5ad3939 --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateDrupal7TestBase.php @@ -0,0 +1,24 @@ +installConfig(static::$modules); + + // Load database dumps to provide source data. + $dumps = array( + $this->getDumpDirectory() . '/FieldConfig.php', + $this->getDumpDirectory() . '/FieldConfigInstance.php', + ); + $this->loadDumps($dumps); + + $this->createType('page'); + $this->createType('article'); + $this->createType('blog'); + $this->createType('book'); + $this->createType('forum'); + $this->createType('test_content_type'); + + $migration = entity_load('migration', 'd7_field'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + + $migration = entity_load('migration', 'd7_field_instance'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + private function createType($id) { + entity_create('node_type', array( + 'type' => $id, + 'label' => $this->randomString(), + ))->save(); + + entity_create('comment_type', array( + 'id' => 'comment_node_' . $id, + 'label' => $this->randomString(), + 'target_entity_type_id' => 'node', + ))->save(); + } + + private function assertEntity($id) { + $field = FieldConfig::load($id); + $this->assertTrue($field instanceof FieldConfigInterface); + } + + public function testFieldInstances() { + $this->assertEntity('comment.comment_node_page.comment_body'); + $this->assertEntity('node.page.body'); + $this->assertEntity('comment.comment_node_article.comment_body'); + $this->assertEntity('node.article.body'); + $this->assertEntity('node.article.field_tags'); + $this->assertEntity('node.article.field_image'); + $this->assertEntity('comment.comment_node_blog.comment_body'); + $this->assertEntity('node.blog.body'); + $this->assertEntity('comment.comment_node_book.comment_body'); + $this->assertEntity('node.book.body'); + $this->assertEntity('node.forum.taxonomy_forums'); + $this->assertEntity('comment.comment_node_forum.comment_body'); + $this->assertEntity('node.forum.body'); + $this->assertEntity('comment.comment_node_test_content_type.comment_body'); + $this->assertEntity('node.test_content_type.field_boolean'); + $this->assertEntity('node.test_content_type.field_email'); + $this->assertEntity('node.test_content_type.field_phone'); + $this->assertEntity('node.test_content_type.field_date'); + $this->assertEntity('node.test_content_type.field_date_with_end_time'); + $this->assertEntity('node.test_content_type.field_file'); + $this->assertEntity('node.test_content_type.field_float'); + $this->assertEntity('node.test_content_type.field_images'); + $this->assertEntity('node.test_content_type.field_integer'); + $this->assertEntity('node.test_content_type.field_link'); + $this->assertEntity('node.test_content_type.field_text_list'); + $this->assertEntity('node.test_content_type.field_integer_list'); + $this->assertEntity('node.test_content_type.field_long_text'); + $this->assertEntity('node.test_content_type.field_term_reference'); + $this->assertEntity('node.test_content_type.field_text'); + $this->assertEntity('comment.comment_node_test_content_type.field_integer'); + $this->assertEntity('user.user.field_file'); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateFieldTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateFieldTest.php new file mode 100644 index 0000000..a24bc02 --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateFieldTest.php @@ -0,0 +1,139 @@ +installConfig(static::$modules); + + // Load database dumps to provide source data. + $dumps = array( + $this->getDumpDirectory() . '/FieldConfig.php', + $this->getDumpDirectory() . '/FieldConfigInstance.php', + ); + $this->loadDumps($dumps); + } + + private function executeMigration() { + $migration = entity_load('migration', 'd7_field'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + private function only($field) { + // Delete everything but the text fields. + Database::getConnection('default', 'migrate') + ->delete('field_config') + ->condition('field_name', (array) $field, 'NOT IN') + ->execute(); + } + + private function assertEntity($id) { + $field = FieldStorageConfig::load($id); + $this->assertTrue($field instanceof FieldStorageConfigInterface); + } + + public function testLongTextWithSummaryFields() { + $this->only(['body', 'field_long_text']); + $this->executeMigration(); + $this->assertEntity('node.body'); + $this->assertEntity('node.field_long_text'); + } + + public function testLongTextField() { + $this->only('comment_body'); + $this->executeMigration(); + $this->assertEntity('comment.comment_body'); + } + + public function testFileFields() { + $this->only('field_file'); + $this->executeMigration(); + $this->assertEntity('node.field_file'); + $this->assertEntity('user.field_file'); + } + + public function testFloatField() { + $this->only('field_float'); + $this->executeMigration(); + $this->assertEntity('node.field_float'); + } + + public function testImageFields() { + $this->only(['field_image', 'field_images']); + $this->executeMigration(); + $this->assertEntity('node.field_image'); + $this->assertEntity('node.field_images'); + } + + public function testIntegerFields() { + $this->only(['field_integer', 'field_integer_list']); + $this->executeMigration(); + $this->assertEntity('node.field_integer'); + $this->assertEntity('comment.field_integer'); + $this->assertEntity('node.field_integer_list'); + } + + public function testLinkField() { + $this->only('field_link'); + $this->executeMigration(); + $this->assertEntity('node.field_link'); + } + + public function testTermReferenceFields() { + $this->only(['field_tags', 'field_term_reference', 'taxonomy_forums']); + $this->executeMigration(); + $this->assertEntity('node.field_tags'); + $this->assertEntity('node.field_term_reference'); + $this->assertEntity('node.taxonomy_forums'); + } + + public function testTextFields() { + $this->only(['field_text', 'field_text_list']); + $this->executeMigration(); + $this->assertEntity('node.field_text'); + $this->assertEntity('node.field_text_list'); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateImageSettingsTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateImageSettingsTest.php new file mode 100644 index 0000000..b207ea9 --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateImageSettingsTest.php @@ -0,0 +1,57 @@ +installConfig(['image']); + + // Load database dumps to provide source data. + $dumps = array( + $this->getDumpDirectory() . '/Variable.php', + ); + $this->loadDumps($dumps); + + // Migrate users. + $migration = entity_load('migration', 'd7_image_settings'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the migration. + */ + public function testMigration() { + $settings = \Drupal::config('image.settings')->get(); + $this->assertIdentical(TRUE, $settings['allow_insecure_derivatives']); + $this->assertIdentical(TRUE, $settings['suppress_itok_output']); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateSystemAuthorizeTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateSystemAuthorizeTest.php new file mode 100644 index 0000000..50008ca --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateSystemAuthorizeTest.php @@ -0,0 +1,53 @@ +getDumpDirectory() . '/Variable.php', + ); + $this->loadDumps($dumps); + + // Migrate users. + $migration = entity_load('migration', 'd7_system_authorize'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the migration. + */ + public function testMigration() { + $this->assertIdentical('ftp', \Drupal::config('system.authorize')->get('filetransfer_default')); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyTermTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyTermTest.php new file mode 100644 index 0000000..515a33c --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyTermTest.php @@ -0,0 +1,120 @@ +installEntitySchema('taxonomy_term'); + + $this->prepareMigrations(array( + 'd7_taxonomy_vocabulary' => array( + array(array(1), array('tags')), + array(array(2), array('forums')), + array(array(3), array('test_vocabulary')), + ))); + /** @var \Drupal\migrate\entity\Migration $migration */ + $migration = entity_load('migration', 'd7_taxonomy_term'); + $dumps = array( + $this->getDumpDirectory() . '/TaxonomyTermData.php', + $this->getDumpDirectory() . '/TaxonomyTermHierarchy.php', + $this->getDumpDirectory() . '/TaxonomyVocabulary.php', + ); + $this->prepare($migration, $dumps); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the Drupal 7 taxonomy term to Drupal 8 migration. + */ + public function testTaxonomyTerms() { + $storage = $this->container->get('entity.manager')->getStorage('taxonomy_term'); + + /** @var \Drupal\taxonomy\TermInterface $term */ + $term = Term::load(1); + $this->assertIdentical('General discussion', $term->label()); + $this->assertIdentical('forums', $term->getVocabularyId()); + $this->assertEqual('', $term->getDescription()); + $this->assertEqual(2, $term->getWeight()); + $this->assertIdentical([], $this->getParentIDs(1)); + + $term = Term::load(2); + $this->assertIdentical('Term1', $term->label()); + $this->assertIdentical('test_vocabulary', $term->getVocabularyId()); + $this->assertIdentical('The first term.', $term->getDescription()); + $this->assertEqual(0, $term->getWeight()); + $this->assertIdentical([], $this->getParentIDs(2)); + + $term = Term::load(3); + $this->assertIdentical('Term2', $term->label()); + $this->assertIdentical('test_vocabulary', $term->getVocabularyId()); + $this->assertIdentical('The second term.', $term->getDescription()); + $this->assertEqual(0, $term->getWeight()); + $this->assertIdentical([], $this->getParentIDs(3)); + + $term = Term::load(4); + $this->assertIdentical('Term3', $term->label()); + $this->assertIdentical('test_vocabulary', $term->getVocabularyId()); + $this->assertIdentical('The third term.', $term->getDescription()); + $this->assertEqual(0, $term->getWeight()); + $this->assertIdentical([3], $this->getParentIDs(4)); + + $term = Term::load(5); + $this->assertIdentical('Custom Forum', $term->label()); + $this->assertIdentical('forums', $term->getVocabularyId()); + $this->assertEqual('Where the cool kids are.', $term->getDescription()); + $this->assertEqual(3, $term->getWeight()); + $this->assertIdentical([], $this->getParentIDs(5)); + + $term = Term::load(6); + $this->assertIdentical('Games', $term->label()); + $this->assertIdentical('forums', $term->getVocabularyId()); + $this->assertEqual('', $term->getDescription()); + $this->assertEqual(4, $term->getWeight()); + $this->assertIdentical([], $this->getParentIDs(6)); + + $term = Term::load(7); + $this->assertIdentical('Minecraft', $term->label()); + $this->assertIdentical('forums', $term->getVocabularyId()); + $this->assertEqual('', $term->getDescription()); + $this->assertEqual(1, $term->getWeight()); + $this->assertIdentical([6], $this->getParentIDs(7)); + + $term = Term::load(8); + $this->assertIdentical('Half Life 3', $term->label()); + $this->assertIdentical('forums', $term->getVocabularyId()); + $this->assertEqual('', $term->getDescription()); + $this->assertEqual(0, $term->getWeight()); + $this->assertIdentical([6], $this->getParentIDs(8)); + } + + private function getParentIDs($tid) { + return array_keys(\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid)); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyVocabularyTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyVocabularyTest.php new file mode 100644 index 0000000..c06ac54 --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateTaxonomyVocabularyTest.php @@ -0,0 +1,72 @@ +getDumpDirectory() . '/TaxonomyVocabulary.php', + ); + $this->prepare($migration, $dumps); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration. + */ + public function testTaxonomyVocabulary() { + /** @var \Drupal\taxonomy\VocabularyInterface $vocabulary */ + $vocabulary = Vocabulary::load('tags'); + $this->assertIdentical('Tags', $vocabulary->label()); + $this->assertIdentical('Use tags to group articles on similar topics into categories.', $vocabulary->getDescription()); + $this->assertIdentical(TAXONOMY_HIERARCHY_DISABLED, $vocabulary->getHierarchy()); + // @TODO Check 'module' property + // @TODO Check 'weight' property + + /** @var \Drupal\taxonomy\VocabularyInterface $vocabulary */ + $vocabulary = Vocabulary::load('forums'); + $this->assertIdentical('Forums', $vocabulary->label()); + $this->assertIdentical('Forum navigation vocabulary', $vocabulary->getDescription()); + $this->assertIdentical(TAXONOMY_HIERARCHY_SINGLE, $vocabulary->getHierarchy()); + // @TODO Check 'module' property + // @TODO Check 'weight' property + + /** @var \Drupal\taxonomy\VocabularyInterface $vocabulary */ + $vocabulary = Vocabulary::load('test_vocabulary'); + $this->assertIdentical('Test Vocabulary', $vocabulary->label()); + $this->assertIdentical('This is the vocabulary description', $vocabulary->getDescription()); + $this->assertIdentical(TAXONOMY_HIERARCHY_SINGLE, $vocabulary->getHierarchy()); + // @TODO Check 'module' property + // @TODO Check 'weight' property + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateUserFloodTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateUserFloodTest.php new file mode 100644 index 0000000..d9c233d --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateUserFloodTest.php @@ -0,0 +1,60 @@ +installConfig(['user']); + + // Load database dumps to provide source data. + $dumps = array( + $this->getDumpDirectory() . '/Variable.php', + ); + $this->loadDumps($dumps); + + // Migrate users. + $migration = entity_load('migration', 'd7_user_flood'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the migration. + */ + public function testMigration() { + $expected = [ + 'uid_only' => TRUE, + 'ip_limit' => 30, + 'ip_window' => 7200, + 'user_limit' => 22, + 'user_window' => 86400, + ]; + $this->assertIdentical($expected, \Drupal::config('user.flood')->get()); + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d7/MigrateUserTest.php b/core/modules/migrate_drupal/src/Tests/d7/MigrateUserTest.php new file mode 100644 index 0000000..4bf3b69 --- /dev/null +++ b/core/modules/migrate_drupal/src/Tests/d7/MigrateUserTest.php @@ -0,0 +1,150 @@ +installEntitySchema('file'); + $this->installSchema('file', ['file_usage']); + + // Create the user profile field and instance. + entity_create('field_storage_config', array( + 'entity_type' => 'user', + 'field_name' => 'user_picture', + 'type' => 'image', + 'translatable' => '0', + ))->save(); + entity_create('field_config', array( + 'label' => 'User Picture', + 'description' => '', + 'field_name' => 'user_picture', + 'entity_type' => 'user', + 'bundle' => 'user', + 'required' => 0, + ))->save(); + + $file = entity_create('file', array( + 'fid' => 2, + 'uid' => 2, + 'filename' => 'image-test.jpg', + 'uri' => "public://image-test.jpg", + 'filemime' => 'image/jpeg', + 'created' => 1, + 'changed' => 1, + 'status' => FILE_STATUS_PERMANENT, + )); + $file->enforceIsNew(); + file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png')); + $file->save(); + + $file = entity_create('file', array( + 'fid' => 8, + 'uid' => 8, + 'filename' => 'image-test.png', + 'uri' => "public://image-test.png", + 'filemime' => 'image/png', + 'created' => 1, + 'changed' => 1, + 'status' => FILE_STATUS_PERMANENT, + )); + $file->enforceIsNew(); + file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-2.jpg')); + $file->save(); + + // Load database dumps to provide source data. + $dumps = array( + $this->getDumpDirectory() . '/Users.php', + ); + $this->loadDumps($dumps); + + // Migrate users. + $migration = entity_load('migration', 'd7_user'); + $executable = new MigrateExecutable($migration, $this); + $executable->import(); + } + + /** + * Tests the Drupal 7 user to Drupal 8 migration. + */ + public function testUser() { + $users = Database::getConnection('default', 'migrate') + ->select('users', 'u') + ->fields('u') + ->execute() + ->fetchAll(); + + foreach ($users as $source) { + $roles = array(RoleInterface::AUTHENTICATED_ID); + + /** @var \Drupal\user\UserInterface $user */ + $user = User::load($source->uid); + $this->assertIdentical($source->uid, $user->id()); + $this->assertIdentical($source->name, $user->label()); + $this->assertIdentical($source->mail, $user->getEmail()); + $this->assertIdentical($source->created, $user->getCreatedTime()); + $this->assertIdentical($source->access, $user->getLastAccessedTime()); + $this->assertIdentical($source->login, $user->getLastLoginTime()); + $is_blocked = $source->status == 0; + $this->assertIdentical($is_blocked, $user->isBlocked()); + // $user->getPreferredLangcode() might fallback to default language if the + // user preferred language is not configured on the site. We just want to + // test if the value was imported correctly. + $this->assertIdentical($source->language, $user->preferred_langcode->value); + // $time_zone = $source->expected_timezone ?: $this->config('system.date')->get('timezone.default'); + // $this->assertIdentical($time_zone, $user->getTimeZone()); + $this->assertIdentical($source->init, $user->getInitialEmail()); + $this->assertIdentical($roles, $user->getRoles()); + + // We have one empty picture in the data so don't try load that. + if (!empty($source->picture)) { + // Test the user picture. + $file = File::load($user->user_picture->target_id); + $this->assertIdentical(basename($source->picture), $file->getFilename()); + } + + // Use the API to check if the password has been salted and re-hashed to + // conform the Drupal >= 7. + // $this->assertTrue(\Drupal::service('password')->check($source->pass_plain, $user)); + } + } + +}