From 181b12210e93ddffc6deb325371e9e4f64f1ed11 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Mon, 12 May 2014 22:10:20 -0700 Subject: [PATCH] Issue #2260239 by ultimike: D6->D8 Profile field (checkbox). --- ...ration.d6_user_profile_entity_form_display.yml | 8 +++++++- .../migrate.migration.d6_user_profile_field.yml | 2 +- .../Tests/Dump/Drupal6UserProfileFields.php | 15 +++++++++++++++ .../Tests/d6/MigrateProfileValuesTest.php | 7 ++++++- .../d6/MigrateUserProfileEntityDisplayTest.php | 7 ++++++- .../MigrateUserProfileEntityFormDisplayTest.php | 12 +++++++++++- .../d6/MigrateUserProfileFieldInstanceTest.php | 8 +++++++- .../Tests/d6/MigrateUserProfileFieldTest.php | 2 +- 8 files changed, 54 insertions(+), 7 deletions(-) diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_entity_form_display.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_entity_form_display.yml index c74b37f30827..6dc614847765 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_entity_form_display.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_entity_form_display.yml @@ -18,7 +18,7 @@ process: plugin: static_map source: type map: - checkbox: options_select + checkbox: options_onoff date: datetime_default list: text_textfield selection: options_select @@ -32,6 +32,12 @@ process: source: - @type - constants.empty # we don't have any settings. + 'options.settings.display_label': # Single on/off checkboxes need to have display_label = true otherwise their label doesn't show. + plugin: static_map + default_value: false + source: type + map: + checkbox: true hidden: plugin: static_map source: visibility diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml index fb9217c989c3..183a2657d0f1 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml @@ -11,7 +11,7 @@ process: plugin: static_map source: type map: - checkbox: list_integer + checkbox: list_boolean date: datetime list: text selection: list_text diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php index 3d3d0178c785..b1d4e73b413c 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserProfileFields.php @@ -235,6 +235,21 @@ public static function getData($table) { 'autocomplete' => '0', 'options' => '', ), + array( + 'fid' => '15', + 'title' => 'I love migrations', + 'name' => 'profile_love_migrations', + 'explanation' => "If you check this box, you love migrations.", + 'category' => 'Personal information', + 'page' => 'People who love migrations', + 'type' => 'checkbox', + 'weight' => '-15', + 'required' => '0', + 'register' => '0', + 'visibility' => '2', + 'autocomplete' => '0', + 'options' => '', + ), ), ); diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php index e3e6d7edf116..73ff29d60583 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateProfileValuesTest.php @@ -61,7 +61,7 @@ protected function setUp() { entity_create('field_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', - 'type' => 'list_integer', + 'type' => 'list_boolean', ))->save(); entity_create('field_config', array( 'entity_type' => 'user', @@ -84,6 +84,11 @@ protected function setUp() { 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); + entity_create('field_config', array( + 'entity_type' => 'user', + 'name' => 'profile_love_migrations', + 'type' => 'list_boolean', + ))->save(); // Create the field instances. foreach (Drupal6UserProfileFields::getData('profile_fields') as $field) { diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php index 372126f1a602..e29143e9269f 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityDisplayTest.php @@ -54,7 +54,7 @@ protected function setUp() { entity_create('field_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', - 'type' => 'list_integer', + 'type' => 'list_boolean', ))->save(); entity_create('field_config', array( 'entity_type' => 'user', @@ -77,6 +77,11 @@ protected function setUp() { 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); + entity_create('field_config', array( + 'entity_type' => 'user', + 'name' => 'profile_love_migrations', + 'type' => 'list_boolean', + ))->save(); $field_data = Drupal6UserProfileFields::getData('profile_fields'); foreach ($field_data as $field) { entity_create('field_instance_config', array( diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php index 40257e991a8b..947b6622c7d8 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php @@ -49,7 +49,7 @@ protected function setUp() { entity_create('field_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', - 'type' => 'list_integer', + 'type' => 'list_boolean', ))->save(); entity_create('field_config', array( 'entity_type' => 'user', @@ -72,6 +72,11 @@ protected function setUp() { 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); + entity_create('field_config', array( + 'entity_type' => 'user', + 'name' => 'profile_love_migrations', + 'type' => 'list_boolean', + ))->save(); $field_data = Drupal6UserProfileFields::getData('profile_fields'); foreach ($field_data as $field) { entity_create('field_instance_config', array( @@ -116,6 +121,11 @@ public function testUserProfileEntityFormDisplay() { // Test PROFILE_HIDDEN field is hidden. $this->assertNull($display->getComponent('profile_sold_to')); + + // Test that a checkbox field has the proper display label setting. + $component = $display->getComponent('profile_love_migrations'); + $this->assertEqual($component['type'], 'options_onoff'); + $this->assertEqual($component['settings']['display_label'], true); } } diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php index 7393fea5ed63..db8ac08c4902 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldInstanceTest.php @@ -92,6 +92,11 @@ public function testUserProfileFields() { $field = entity_load('field_instance_config', 'user.user.profile_birthdate'); $this->assertEqual($field->label(), 'Birthdate'); $this->assertEqual($field->getDescription(), "Enter your birth date and we'll send you a coupon."); + + // Another migrated checkbox field, with a different source visibility setting. + $field = entity_load('field_instance_config', 'user.user.profile_love_migrations'); + $this->assertEqual($field->label(), 'I love migrations'); + $this->assertEqual($field->getDescription(), "If you check this box, you love migrations."); } /** @@ -101,11 +106,12 @@ protected function createFields() { $fields = array( 'profile_color' => 'text', 'profile_biography' => 'text_long', - 'profile_sell_address' => 'list_integer', + 'profile_sell_address' => 'list_boolean', 'profile_sold_to' => 'list_text', 'profile_bands' => 'text', 'profile_blog' => 'link', 'profile_birthdate' => 'datetime', + 'profile_love_migrations' => 'list_boolean', ); foreach ($fields as $name => $type) { entity_create('field_config', array( diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php index 696695c348ca..69af4a04a70a 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserProfileFieldTest.php @@ -58,7 +58,7 @@ public function testUserProfileFields() { // Migrated checkbox field. $field = entity_load('field_config', 'user.profile_sell_address'); - $this->assertEqual($field->type, 'list_integer', 'Field type is list_integer.'); + $this->assertEqual($field->type, 'list_boolean', 'Field type is list_boolean.'); // Migrated selection field. $field = entity_load('field_config', 'user.profile_sold_to'); -- GitLab