You are here

public function BookTest::providerSource in Drupal 10

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

Class

BookTest
@covers \Drupal\book\Plugin\migrate\source\Book @group book

Namespace

Drupal\Tests\book\Kernel\Plugin\migrate\source

Code

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

  // The source data.
  $tests[0]['source_data']['book'] = [
    [
      'mlid' => '1',
      'nid' => '4',
      'bid' => '4',
    ],
  ];
  $tests[0]['source_data']['menu_links'] = [
    [
      'menu_name' => 'book-toc-1',
      'mlid' => '1',
      'plid' => '0',
      'link_path' => 'node/4',
      'router_path' => 'node/%',
      'link_title' => 'Test top book title',
      'options' => 'a:0:{}',
      'module' => 'book',
      'hidden' => '0',
      'external' => '0',
      'has_children' => '1',
      'expanded' => '0',
      'weight' => '-10',
      'depth' => '1',
      'customized' => '0',
      'p1' => '1',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'nid' => '4',
      'bid' => '4',
      'mlid' => '1',
      'plid' => '0',
      'weight' => '-10',
      'p1' => '1',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
    ],
  ];
  return $tests;
}