You are here

public function LanguageContentTaxonomyVocabularySettingsTest::providerSource in Drupal 8

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

Class

LanguageContentTaxonomyVocabularySettingsTest
Tests i18ntaxonomy vocabulary setting source plugin.

Namespace

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

Code

public function providerSource() {
  $tests = [];

  // The source data.
  $tests[0]['source_data']['vocabulary'] = [
    [
      'vid' => 1,
      'name' => 'Tags',
      'description' => 'Tags description.',
      'help' => 1,
      'relations' => 0,
      'hierarchy' => 0,
      'multiple' => 0,
      'required' => 0,
      'tags' => 1,
      'module' => 'taxonomy',
      'weight' => 0,
      'language' => '',
    ],
    [
      'vid' => 2,
      'name' => 'Categories',
      'description' => 'Categories description.',
      'help' => 1,
      'relations' => 1,
      'hierarchy' => 1,
      'multiple' => 0,
      'required' => 1,
      'tags' => 0,
      'module' => 'taxonomy',
      'weight' => 0,
      'language' => 'zu',
    ],
  ];
  $tests[0]['source_data']['variable'] = [
    [
      'name' => 'i18ntaxonomy_vocabulary',
      'value' => 'a:4:{i:1;s:1:"3";i:2;s:1:"2";i:3;s:1:"3";i:5;s:1:"1";}',
    ],
  ];
  $tests[0]['expected_data'] = [
    [
      'vid' => 1,
      'language' => '',
      'state' => 3,
    ],
    [
      'vid' => 2,
      'language' => 'zu',
      'state' => 2,
    ],
  ];

  // Test without a language column in the database.
  $tests[1] = $tests[0];
  foreach ($tests[1]['source_data']['vocabulary'] as $key => $row) {
    unset($tests[1]['source_data']['vocabulary'][$key]['language']);
  }
  $tests[1]['source_data']['variable'] = [
    [
      'name' => 'i18ntaxonomy_vocabulary',
      'value' => 'a:4:{i:1;s:1:"0";i:2;s:1:"0";i:3;s:1:"3";i:5;s:1:"1";}',
    ],
  ];
  $tests[1]['expected_data'] = [
    [
      'vid' => 1,
      'state' => 0,
    ],
    [
      'vid' => 2,
      'state' => 0,
    ],
  ];

  // Test without a i18ntaxonomy_vocabulary variable.
  $tests[2] = $tests[1];
  unset($tests[2]['source_data']['variable']);
  return $tests;
}