You are here

public function MenuLinkTranslationTest::providerSource in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/d6/MenuLinkTranslationTest.php \Drupal\Tests\menu_link_content\Kernel\Plugin\migrate\source\d6\MenuLinkTranslationTest::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/menu_link_content/tests/src/Kernel/Plugin/migrate/source/d6/MenuLinkTranslationTest.php, line 23

Class

MenuLinkTranslationTest
Tests menu link translation source plugin.

Namespace

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

Code

public function providerSource() {
  $test = [];
  $test[0]['source_data']['menu_links'] = [
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 138,
      'plid' => 0,
      'link_path' => 'admin',
      'router_path' => 'admin',
      'link_title' => 'Test 1',
      'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 1";}}',
      'module' => 'menu',
      'hidden' => 0,
      'external' => 0,
      'has_children' => 1,
      'expanded' => 0,
      'weight' => 15,
      'depth' => 1,
      'customized' => 1,
      'p1' => '138',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 139,
      'plid' => 138,
      'link_path' => 'admin/modules',
      'router_path' => 'admin/modules',
      'link_title' => 'Test 2',
      'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
      'module' => 'menu',
      'hidden' => 0,
      'external' => 0,
      'has_children' => 0,
      'expanded' => 0,
      'weight' => 12,
      'depth' => 2,
      'customized' => 1,
      'p1' => '138',
      'p2' => '139',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 140,
      'plid' => 0,
      'link_path' => 'https://www.drupal.org',
      'router_path' => 'admin/modules',
      'link_title' => 'Test 2',
      'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
      'module' => 'menu',
      'hidden' => 0,
      'external' => 0,
      'has_children' => 0,
      'expanded' => 0,
      'weight' => 12,
      'depth' => 2,
      'customized' => 1,
      'p1' => '0',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 141,
      'plid' => 0,
      'link_path' => 'https://api.drupal.org/api/drupal/8.3.x',
      'router_path' => 'admin/modules',
      'link_title' => 'Test 3',
      'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 3";}}',
      'module' => 'menu',
      'hidden' => 0,
      'external' => 0,
      'has_children' => 0,
      'expanded' => 0,
      'weight' => 12,
      'depth' => 2,
      'customized' => 1,
      'p1' => '0',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
    ],
  ];
  $test[0]['source_data']['i18n_strings'] = [
    [
      'lid' => 1,
      'objectid' => 139,
      'type' => 'item',
      'property' => 'title',
      'objectindex' => 0,
      'format' => 0,
    ],
    [
      'lid' => 2,
      'objectid' => 139,
      'type' => 'item',
      'property' => 'description',
      'objectindex' => 0,
      'format' => 0,
    ],
    [
      'lid' => 3,
      'objectid' => 140,
      'type' => 'item',
      'property' => 'description',
      'objectindex' => 0,
      'format' => 0,
    ],
    [
      'lid' => 4,
      'objectid' => 141,
      'type' => 'item',
      'property' => 'title',
      'objectindex' => 0,
      'format' => 0,
    ],
  ];
  $test[0]['source_data']['locales_target'] = [
    [
      'lid' => 1,
      'language' => 'fr',
      'translation' => 'fr - title translation',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
    [
      'lid' => 2,
      'language' => 'fr',
      'translation' => 'fr - description translation',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
    [
      'lid' => 3,
      'language' => 'zu',
      'translation' => 'zu - description translation',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
    [
      'lid' => 4,
      'language' => 'zu',
      'translation' => 'zu - title translation',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
  ];
  $test[0]['expected_results'] = [
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 139,
      'property' => 'title',
      'language' => 'fr',
      'link_title' => 'Test 2',
      'description' => 'Test menu link 2',
      'title_translated' => 'fr - title translation',
      'description_translated' => 'fr - description translation',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 139,
      'property' => 'description',
      'language' => 'fr',
      'link_title' => 'Test 2',
      'description' => 'Test menu link 2',
      'title_translated' => 'fr - title translation',
      'description_translated' => 'fr - description translation',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 140,
      'property' => 'description',
      'language' => 'zu',
      'link_title' => 'Test 2',
      'description' => 'Test menu link 2',
      'title_translated' => NULL,
      'description_translated' => 'zu - description translation',
    ],
    [
      'menu_name' => 'menu-test-menu',
      'mlid' => 141,
      'property' => 'title',
      'language' => 'zu',
      'link_title' => 'Test 3',
      'description' => 'Test menu link 3',
      'title_translated' => 'zu - title translation',
      'description_translated' => NULL,
    ],
  ];
  return $test;
}