You are here

public function FilterFormatTest::providerSource in Drupal 8

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

Class

FilterFormatTest
Tests D7 filter format source plugin.

Namespace

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

Code

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

  // The source data.
  $tests[0]['source_data']['filter_format'] = [
    [
      'format' => 'custom_text_format',
      'name' => 'Custom Text format',
      'cache' => 1,
      'status' => 1,
      'weight' => 0,
    ],
    [
      'format' => 'full_html',
      'name' => 'Full HTML',
      'cache' => 1,
      'status' => 1,
      'weight' => 1,
    ],
  ];
  $tests[0]['source_data']['filter'] = [
    [
      'format' => 'custom_text_format',
      'module' => 'filter',
      'name' => 'filter_autop',
      'weight' => 0,
      'status' => 1,
      'settings' => serialize([]),
    ],
    [
      'format' => 'custom_text_format',
      'module' => 'filter',
      'name' => 'filter_html',
      'weight' => 1,
      'status' => 1,
      'settings' => serialize([]),
    ],
    [
      'format' => 'full_html',
      'module' => 'filter',
      'name' => 'filter_url',
      'weight' => 0,
      'status' => 1,
      'settings' => serialize([]),
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'format' => 'custom_text_format',
      'name' => 'Custom Text format',
      'cache' => 1,
      'status' => 1,
      'weight' => 0,
      'filters' => [
        'filter_autop' => [
          'format' => 'custom_text_format',
          'module' => 'filter',
          'name' => 'filter_autop',
          'weight' => 0,
          'status' => 1,
          'settings' => [],
        ],
        'filter_html' => [
          'format' => 'custom_text_format',
          'module' => 'filter',
          'name' => 'filter_html',
          'weight' => 1,
          'status' => 1,
          'settings' => [],
        ],
      ],
    ],
    [
      'format' => 'full_html',
      'name' => 'Full HTML',
      'cache' => 1,
      'status' => 1,
      'weight' => 1,
      'filters' => [
        'filter_url' => [
          'format' => 'full_html',
          'module' => 'filter',
          'name' => 'filter_url',
          'weight' => 0,
          'status' => 1,
          'settings' => [],
        ],
      ],
    ],
  ];
  return $tests;
}