You are here

public function BlockTranslationTest::providerSource in Drupal 8

Same name in this branch
  1. 8 core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php \Drupal\Tests\block\Kernel\Plugin\migrate\source\d6\BlockTranslationTest::providerSource()
  2. 8 core/modules/block/tests/src/Kernel/Plugin/migrate/source/d7/BlockTranslationTest.php \Drupal\Tests\block\Kernel\Plugin\migrate\source\d7\BlockTranslationTest::providerSource()
Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Kernel/Plugin/migrate/source/d7/BlockTranslationTest.php \Drupal\Tests\block\Kernel\Plugin\migrate\source\d7\BlockTranslationTest::providerSource()
  2. 10 core/modules/block/tests/src/Kernel/Plugin/migrate/source/d7/BlockTranslationTest.php \Drupal\Tests\block\Kernel\Plugin\migrate\source\d7\BlockTranslationTest::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/block/tests/src/Kernel/Plugin/migrate/source/d7/BlockTranslationTest.php, line 24

Class

BlockTranslationTest
Tests i18n block source plugin.

Namespace

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

Code

public function providerSource() {

  // The source data.
  $tests[0]['source_data']['block'] = [
    [
      'bid' => 1,
      'module' => 'system',
      'delta' => 'main',
      'theme' => 'bartik',
      'status' => 1,
      'weight' => 0,
      'region' => 'content',
      'custom' => '0',
      'visibility' => 0,
      'pages' => '',
      'title' => '',
      'cache' => -1,
      'i18n_mode' => 1,
    ],
    [
      'bid' => 2,
      'module' => 'system',
      'delta' => 'navigation',
      'theme' => 'bartik',
      'status' => 1,
      'weight' => 0,
      'region' => 'sidebar_first',
      'custom' => '0',
      'visibility' => 0,
      'pages' => '',
      'title' => 'Navigation',
      'cache' => -1,
      'i18n_mode' => 1,
    ],
  ];
  $tests[0]['source_data']['block_role'] = [
    [
      'module' => 'block',
      'delta' => 1,
      'rid' => 2,
    ],
    [
      'module' => 'block',
      'delta' => 2,
      'rid' => 2,
    ],
    [
      'module' => 'block',
      'delta' => 2,
      'rid' => 100,
    ],
  ];
  $tests[0]['source_data']['i18n_string'] = [
    [
      'lid' => 1,
      'textgroup' => 'block',
      'context' => '1',
      'objectid' => 'navigation',
      'type' => 'system',
      'property' => 'title',
      'objectindex' => 0,
      'format' => '',
    ],
    [
      'lid' => 2,
      'textgroup' => 'block',
      'context' => '1',
      'objectid' => 'main',
      'type' => 'system',
      'property' => 'title',
      'objectindex' => 0,
      'format' => '',
    ],
  ];
  $tests[0]['source_data']['locales_target'] = [
    [
      'lid' => 1,
      'translation' => 'fr - Navigation',
      'language' => 'fr',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
  ];
  $tests[0]['source_data']['role'] = [
    [
      'rid' => 2,
      'name' => 'authenticated user',
    ],
  ];
  $tests[0]['source_data']['system'] = [
    [
      'filename' => 'modules/system/system.module',
      'name' => 'system',
      'type' => 'module',
      'owner' => '',
      'status' => '1',
      'throttle' => '0',
      'bootstrap' => '0',
      'schema_version' => '7055',
      'weight' => '0',
      'info' => 'a:0:{}',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'bid' => 2,
      'module' => 'system',
      'delta' => 'navigation',
      'theme' => 'bartik',
      'status' => 1,
      'weight' => 0,
      'region' => 'sidebar_first',
      'custom' => '0',
      'visibility' => 0,
      'pages' => '',
      'title' => 'Navigation',
      'cache' => -1,
      'i18n_mode' => 1,
      'lid' => 1,
      'translation' => 'fr - Navigation',
      'language' => 'fr',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
  ];

  // Change the name of the locale_target i18n status field.
  $tests[1] = $tests[0];
  foreach ($tests[1]['source_data']['locales_target'] as &$lt) {
    $lt['status'] = $lt['i18n_status'];
    unset($lt['i18n_status']);
  }
  $tests[1]['expected_data'] = [
    [
      'bid' => 2,
      'module' => 'system',
      'delta' => 'navigation',
      'theme' => 'bartik',
      'status' => 1,
      'weight' => 0,
      'region' => 'sidebar_first',
      'custom' => '0',
      'visibility' => 0,
      'pages' => '',
      'title' => 'Navigation',
      'cache' => -1,
      'i18n_mode' => 1,
      'lid' => 1,
      'translation' => 'fr - Navigation',
      'language' => 'fr',
      'plid' => 0,
      'plural' => 0,
      'i18n_status' => 0,
    ],
  ];
  return $tests;
}