Commit 181b1221 authored by webchick's avatar webchick

Issue #2260239 by ultimike: D6->D8 Profile field (checkbox).

parent f710b045
...@@ -18,7 +18,7 @@ process: ...@@ -18,7 +18,7 @@ process:
plugin: static_map plugin: static_map
source: type source: type
map: map:
checkbox: options_select checkbox: options_onoff
date: datetime_default date: datetime_default
list: text_textfield list: text_textfield
selection: options_select selection: options_select
...@@ -32,6 +32,12 @@ process: ...@@ -32,6 +32,12 @@ process:
source: source:
- @type - @type
- constants.empty # we don't have any settings. - 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: hidden:
plugin: static_map plugin: static_map
source: visibility source: visibility
......
...@@ -11,7 +11,7 @@ process: ...@@ -11,7 +11,7 @@ process:
plugin: static_map plugin: static_map
source: type source: type
map: map:
checkbox: list_integer checkbox: list_boolean
date: datetime date: datetime
list: text list: text
selection: list_text selection: list_text
......
...@@ -235,6 +235,21 @@ public static function getData($table) { ...@@ -235,6 +235,21 @@ public static function getData($table) {
'autocomplete' => '0', 'autocomplete' => '0',
'options' => '', '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' => '',
),
), ),
); );
......
...@@ -61,7 +61,7 @@ protected function setUp() { ...@@ -61,7 +61,7 @@ protected function setUp() {
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
'name' => 'profile_sell_address', 'name' => 'profile_sell_address',
'type' => 'list_integer', 'type' => 'list_boolean',
))->save(); ))->save();
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
...@@ -84,6 +84,11 @@ protected function setUp() { ...@@ -84,6 +84,11 @@ protected function setUp() {
'name' => 'profile_birthdate', 'name' => 'profile_birthdate',
'type' => 'datetime', 'type' => 'datetime',
))->save(); ))->save();
entity_create('field_config', array(
'entity_type' => 'user',
'name' => 'profile_love_migrations',
'type' => 'list_boolean',
))->save();
// Create the field instances. // Create the field instances.
foreach (Drupal6UserProfileFields::getData('profile_fields') as $field) { foreach (Drupal6UserProfileFields::getData('profile_fields') as $field) {
......
...@@ -54,7 +54,7 @@ protected function setUp() { ...@@ -54,7 +54,7 @@ protected function setUp() {
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
'name' => 'profile_sell_address', 'name' => 'profile_sell_address',
'type' => 'list_integer', 'type' => 'list_boolean',
))->save(); ))->save();
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
...@@ -77,6 +77,11 @@ protected function setUp() { ...@@ -77,6 +77,11 @@ protected function setUp() {
'name' => 'profile_birthdate', 'name' => 'profile_birthdate',
'type' => 'datetime', 'type' => 'datetime',
))->save(); ))->save();
entity_create('field_config', array(
'entity_type' => 'user',
'name' => 'profile_love_migrations',
'type' => 'list_boolean',
))->save();
$field_data = Drupal6UserProfileFields::getData('profile_fields'); $field_data = Drupal6UserProfileFields::getData('profile_fields');
foreach ($field_data as $field) { foreach ($field_data as $field) {
entity_create('field_instance_config', array( entity_create('field_instance_config', array(
......
...@@ -49,7 +49,7 @@ protected function setUp() { ...@@ -49,7 +49,7 @@ protected function setUp() {
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
'name' => 'profile_sell_address', 'name' => 'profile_sell_address',
'type' => 'list_integer', 'type' => 'list_boolean',
))->save(); ))->save();
entity_create('field_config', array( entity_create('field_config', array(
'entity_type' => 'user', 'entity_type' => 'user',
...@@ -72,6 +72,11 @@ protected function setUp() { ...@@ -72,6 +72,11 @@ protected function setUp() {
'name' => 'profile_birthdate', 'name' => 'profile_birthdate',
'type' => 'datetime', 'type' => 'datetime',
))->save(); ))->save();
entity_create('field_config', array(
'entity_type' => 'user',
'name' => 'profile_love_migrations',
'type' => 'list_boolean',
))->save();
$field_data = Drupal6UserProfileFields::getData('profile_fields'); $field_data = Drupal6UserProfileFields::getData('profile_fields');
foreach ($field_data as $field) { foreach ($field_data as $field) {
entity_create('field_instance_config', array( entity_create('field_instance_config', array(
...@@ -116,6 +121,11 @@ public function testUserProfileEntityFormDisplay() { ...@@ -116,6 +121,11 @@ public function testUserProfileEntityFormDisplay() {
// Test PROFILE_HIDDEN field is hidden. // Test PROFILE_HIDDEN field is hidden.
$this->assertNull($display->getComponent('profile_sold_to')); $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);
} }
} }
...@@ -92,6 +92,11 @@ public function testUserProfileFields() { ...@@ -92,6 +92,11 @@ public function testUserProfileFields() {
$field = entity_load('field_instance_config', 'user.user.profile_birthdate'); $field = entity_load('field_instance_config', 'user.user.profile_birthdate');
$this->assertEqual($field->label(), 'Birthdate'); $this->assertEqual($field->label(), 'Birthdate');
$this->assertEqual($field->getDescription(), "Enter your birth date and we'll send you a coupon."); $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() { ...@@ -101,11 +106,12 @@ protected function createFields() {
$fields = array( $fields = array(
'profile_color' => 'text', 'profile_color' => 'text',
'profile_biography' => 'text_long', 'profile_biography' => 'text_long',
'profile_sell_address' => 'list_integer', 'profile_sell_address' => 'list_boolean',
'profile_sold_to' => 'list_text', 'profile_sold_to' => 'list_text',
'profile_bands' => 'text', 'profile_bands' => 'text',
'profile_blog' => 'link', 'profile_blog' => 'link',
'profile_birthdate' => 'datetime', 'profile_birthdate' => 'datetime',
'profile_love_migrations' => 'list_boolean',
); );
foreach ($fields as $name => $type) { foreach ($fields as $name => $type) {
entity_create('field_config', array( entity_create('field_config', array(
......
...@@ -58,7 +58,7 @@ public function testUserProfileFields() { ...@@ -58,7 +58,7 @@ public function testUserProfileFields() {
// Migrated checkbox field. // Migrated checkbox field.
$field = entity_load('field_config', 'user.profile_sell_address'); $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. // Migrated selection field.
$field = entity_load('field_config', 'user.profile_sold_to'); $field = entity_load('field_config', 'user.profile_sold_to');
......
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