You are here

public function TermNodeTest::providerSource in Drupal 10

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

Class

TermNodeTest
Tests d6_term_node source plugin.

Namespace

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

Code

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

  // The source data.
  $tests[0]['source_data']['term_node'] = [
    [
      'nid' => '1',
      'vid' => '1',
      'tid' => '1',
    ],
    [
      'nid' => '1',
      'vid' => '1',
      'tid' => '4',
    ],
    [
      'nid' => '1',
      'vid' => '1',
      'tid' => '5',
    ],
  ];
  $tests[0]['source_data']['node'] = [
    [
      'nid' => '1',
      'vid' => '1',
      'type' => 'story',
      'language' => '',
      'title' => 'Test title',
      'uid' => '1',
      'status' => '1',
      'created' => '1388271197',
      'changed' => '1420861423',
      'comment' => '0',
      'promote' => '0',
      'moderate' => '0',
      'sticky' => '0',
      'tnid' => '0',
      'translate' => '0',
    ],
  ];
  $tests[0]['source_data']['term_data'] = [
    [
      'tid' => '1',
      'vid' => '3',
      'name' => 'term 1 of vocabulary 3',
      'description' => 'description of term 1 of vocabulary 3',
      'weight' => '0',
    ],
    [
      'tid' => '4',
      'vid' => '3',
      'name' => 'term 4 of vocabulary 3',
      'description' => 'description of term 4 of vocabulary 3',
      'weight' => '6',
    ],
    [
      'tid' => '5',
      'vid' => '3',
      'name' => 'term 5 of vocabulary 3',
      'description' => 'description of term 5 of vocabulary 3',
      'weight' => '7',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'nid' => 1,
      'vid' => 1,
      'type' => 'story',
      'tid' => [
        1,
        4,
        5,
      ],
    ],
  ];

  // Set default value for expected count.
  $tests[0]['expected_count'] = NULL;

  // Set plugin configuration.
  $tests[0]['configuration'] = [
    'vid' => 3,
  ];
  return $tests;
}