You are here

public function MenuTranslationTest::providerSource in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Plugin/migrate/source/d7/MenuTranslationTest.php \Drupal\Tests\system\Kernel\Plugin\migrate\source\d7\MenuTranslationTest::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 MigrateSourceTestBase::providerSource

See also

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

File

core/modules/system/tests/src/Kernel/Plugin/migrate/source/d7/MenuTranslationTest.php, line 23

Class

MenuTranslationTest
Tests the menu translation source plugin.

Namespace

Drupal\Tests\system\Kernel\Plugin\migrate\source\d7

Code

public function providerSource() {
  $tests = [];
  $tests[0]['source_data']['menu_custom'] = [
    [
      'menu_name' => 'navigation',
      'title' => 'Navigation',
      'description' => 'Navigation description',
      'language' => 'und',
      'i18n_mode' => 0,
    ],
    [
      'menu_name' => 'menu-name-2',
      'title' => 'menu custom value 2',
      'description' => 'menu custom description value 2',
      'language' => 'und',
      'i18n_mode' => 0,
    ],
  ];
  $tests[0]['source_data']['i18n_string'] = [
    [
      'lid' => 1,
      'textgroup' => 'menu',
      'context' => ' menu:navigation:description',
      'objectid' => 'navigation',
      'type' => 'menu',
      'property' => 'description',
      'objectindex' => 0,
      'format' => '',
    ],
    [
      'lid' => 2,
      'textgroup' => 'menu',
      'context' => ' menu:navigation:title',
      'objectid' => 'navigation',
      'type' => 'menu',
      'property' => 'title',
      'objectindex' => 0,
      'format' => '',
    ],
  ];
  $tests[0]['source_data']['locales_target'] = [
    [
      'lid' => 1,
      'translation' => 'navigation description translation',
      'language' => 'fr',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
    [
      'lid' => 2,
      'translation' => 'navigation translation',
      'language' => 'fr',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
  ];
  $tests[0]['expected_results'] = [
    [
      'menu_name' => 'navigation',
      'type' => 'menu',
      'property' => 'description',
      'translation' => 'navigation description translation',
      'language' => 'fr',
      'objectid' => 'navigation',
    ],
    [
      'menu_name' => 'navigation',
      'type' => 'menu',
      'property' => 'title',
      'translation' => 'navigation translation',
      'language' => 'fr',
      'objectid' => 'navigation',
    ],
  ];
  return $tests;
}