3 namespace Drupal\Tests\user\Kernel\Plugin\migrate\source;
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
8 * Tests the profile_field source plugin.
10 * @covers \Drupal\user\Plugin\migrate\source\ProfileField
13 class ProfileFieldTest extends MigrateSqlSourceTestBase {
18 public static $modules = ['user', 'migrate_drupal'];
23 public function providerSource() {
27 'expected_data' => [],
34 'title' => 'First name',
35 'name' => 'profile_first_name',
36 'explanation' => 'First name user',
37 'category' => 'profile',
39 'type' => 'textfield',
49 'title' => 'Last name',
50 'name' => 'profile_last_name',
51 'explanation' => 'Last name user',
52 'category' => 'profile',
54 'type' => 'textfield',
65 'name' => 'profile_policy',
66 'explanation' => 'A checkbox that say if you accept policy of website',
67 'category' => 'profile',
80 'name' => 'profile_color',
81 'explanation' => 'A selection that allows user to select a color',
82 'category' => 'profile',
84 'type' => 'selection',
90 'options' => "red\nblue\ngreen",
94 $tests[0]['source_data']['profile_fields'] = $profile_fields;
96 // Profile values are merged with pre-set options of a "selection" field.
97 $tests[0]['source_data']['profile_values'] = [
105 // Expected options are:
106 // for "checkbox" fields - array with NULL options
107 // for "selection" fields - options in both keys and values
108 $expected_field_options = [
116 'yellow' => 'yellow',
120 $tests[0]['expected_data'] = $profile_fields;
122 foreach ($tests[0]['expected_data'] as $delta => $row) {
123 $tests[0]['expected_data'][$delta]['options'] = $expected_field_options[$delta];