class ProfileFieldTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest
Tests the profile_field source plugin.
@covers \Drupal\user\Plugin\migrate\source\ProfileField
@group user
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Kernel\MigrateSourceTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase implements \Drupal\Tests\migrate\Kernel\MigrateSourceTestBase
- class \Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest implements \Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase implements \Drupal\Tests\migrate\Kernel\MigrateSourceTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateSourceTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ProfileFieldTest
1 file declares its use of ProfileFieldTest
- ProfileFieldOptionTranslationTest.php 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 13
Namespace
Drupal\Tests\user\Kernel\Plugin\migrate\sourceView source
class ProfileFieldTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
'migrate_drupal',
];
/**
* {@inheritdoc}
*/
public 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.