function ProfileFieldTest::providerSource
Same name in other branches
- 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest::providerSource()
- 8.9.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest::providerSource()
- 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest::providerSource()
1 call to ProfileFieldTest::providerSource()
- ProfileFieldOptionTranslationTest::providerSource in core/
modules/ user/ tests/ src/ Kernel/ Plugin/ migrate/ source/ d6/ ProfileFieldOptionTranslationTest.php
1 method overrides ProfileFieldTest::providerSource()
- ProfileFieldOptionTranslationTest::providerSource in core/
modules/ user/ tests/ src/ Kernel/ Plugin/ migrate/ source/ d6/ ProfileFieldOptionTranslationTest.php
File
-
core/
modules/ user/ tests/ src/ Kernel/ Plugin/ migrate/ source/ ProfileFieldTest.php, line 25
Class
- ProfileFieldTest
- Tests the profile_field source plugin.
Namespace
Drupal\Tests\user\Kernel\Plugin\migrate\sourceCode
public static function providerSource() {
$tests = [
[
'source_data' => [],
'expected_data' => [],
],
];
$profile_fields = [
[
'fid' => 1,
'title' => 'First name',
'name' => 'profile_first_name',
'explanation' => 'First name user',
'category' => 'profile',
'page' => '',
'type' => 'textfield',
'weight' => 0,
'required' => 1,
'register' => 0,
'visibility' => 2,
'autocomplete' => 0,
'options' => '',
],
[
'fid' => 2,
'title' => 'Last name',
'name' => 'profile_last_name',
'explanation' => 'Last name user',
'category' => 'profile',
'page' => '',
'type' => 'textfield',
'weight' => 0,
'required' => 0,
'register' => 0,
'visibility' => 2,
'autocomplete' => 0,
'options' => '',
],
[
'fid' => 3,
'title' => 'Policy',
'name' => 'profile_policy',
'explanation' => 'A checkbox that say if you accept policy of website',
'category' => 'profile',
'page' => '',
'type' => 'checkbox',
'weight' => 0,
'required' => 1,
'register' => 1,
'visibility' => 2,
'autocomplete' => 0,
'options' => '',
],
[
'fid' => 4,
'title' => 'Color',
'name' => 'profile_color',
'explanation' => 'A selection that allows user to select a color',
'category' => 'profile',
'page' => '',
'type' => 'selection',
'weight' => 0,
'required' => 0,
'register' => 0,
'visibility' => 2,
'autocomplete' => 0,
'options' => "red\nblue\ngreen",
],
];
$tests[0]['source_data']['profile_fields'] = $profile_fields;
// Profile values are merged with pre-set options of a "selection" field.
$tests[0]['source_data']['profile_values'] = [
[
'fid' => 4,
'uid' => 1,
'value' => 'yellow',
],
];
// Expected options are:
// - for "checkbox" fields - array with NULL options.
// - for "selection" fields - options in both keys and values.
$expected_field_options = [
'',
'',
[
NULL,
NULL,
],
[
'red' => 'red',
'blue' => 'blue',
'green' => 'green',
'yellow' => 'yellow',
],
];
$tests[0]['expected_data'] = $profile_fields;
foreach ($tests[0]['expected_data'] as $delta => $row) {
$tests[0]['expected_data'][$delta]['options'] = $expected_field_options[$delta];
}
return $tests;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.