You are here

public function ContactCategoryTest::providerSource in Drupal 10

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

Class

ContactCategoryTest
Tests D6 contact category source plugin.

Namespace

Drupal\Tests\contact\Kernel\Plugin\migrate\source

Code

public function providerSource() {
  $tests = [
    [
      'source_data' => [],
      'expected_data' => [],
    ],
  ];
  $tests[0]['expected_data'] = [
    [
      'cid' => 1,
      'category' => 'contact category value 1',
      'recipients' => [
        'admin@example.com',
        'user@example.com',
      ],
      'reply' => 'auto reply value 1',
      'weight' => 0,
      'selected' => 0,
    ],
    [
      'cid' => 2,
      'category' => 'contact category value 2',
      'recipients' => [
        'admin@example.com',
        'user@example.com',
      ],
      'reply' => 'auto reply value 2',
      'weight' => 0,
      'selected' => 0,
    ],
  ];
  foreach ($tests[0]['expected_data'] as $k => $row) {
    $row['recipients'] = implode(',', $row['recipients']);
    $tests[0]['source_data']['contact'][$k] = $row;
  }
  return $tests;
}