You are here

public function ProfileFieldOptionTranslationTest::providerSource in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d6\ProfileFieldOptionTranslationTest::providerSource()

The data provider.

Return value

array Array of data sets to test, each of which is a numerically indexed array with the following elements:

  • An array of source data, which can be optionally processed and set up by subclasses.
  • An array of expected result rows.
  • (optional) The number of result rows the plugin under test is expected to return. If this is not a numeric value, the plugin will not be counted.
  • (optional) Array of configuration options for the plugin under test.

Overrides ProfileFieldTest::providerSource

See also

\Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::testSource

File

core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php, line 23

Class

ProfileFieldOptionTranslationTest
Tests the field option translation source plugin.

Namespace

Drupal\Tests\user\Kernel\Plugin\migrate\source\d6

Code

public function providerSource() {
  $test = parent::providerSource();

  // The source data.
  $test[0]['source_data']['i18n_strings'] = [
    [
      'lid' => 10,
      'objectid' => 'profile_color',
      'type' => 'field',
      'property' => 'options',
    ],
    [
      'lid' => 1,
      'objectid' => 'profile_last_name',
      'type' => 'field',
      'property' => 'options',
    ],
  ];
  $test[0]['source_data']['locales_target'] = [
    [
      'lid' => 10,
      'translation' => "fr - red\nfr - blue\nfr - green",
      'language' => 'fr',
    ],
  ];
  $test[0]['expected_data'] = [
    [
      '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' => 'red',
        'blue' => 'blue',
        'green' => 'green',
        'yellow' => 'yellow',
      ],
      'property' => 'options',
      'objectid' => 'profile_color',
      'translation' => "fr - red\nfr - blue\nfr - green",
      'language' => 'fr',
    ],
  ];
  return $test;
}