public function FieldInstanceTest::providerSource in Drupal 8
Same name in this branch
- 8 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldInstanceTest::providerSource()
- 8 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldInstanceTest::providerSource()
Same name and namespace in other branches
- 9 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldInstanceTest::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/ field/ tests/ src/ Kernel/ Plugin/ migrate/ source/ d6/ FieldInstanceTest.php, line 23
Class
- FieldInstanceTest
- Tests D6 field instance source plugin.
Namespace
Drupal\Tests\field\Kernel\Plugin\migrate\source\d6Code
public function providerSource() {
$tests = [
[
'source_data' => [],
'expected_data' => [],
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'field_name' => 'field_body',
'type_name' => 'page',
'weight' => 1,
'label' => 'body',
'widget_type' => 'text_textarea',
'description' => '',
'widget_module' => 'text',
'widget_active' => 1,
'required' => 1,
'active' => 1,
'global_settings' => [],
'widget_settings' => [
'rows' => 5,
'size' => 60,
'default_value' => [
[
'value' => '',
'_error_element' => 'default_value_widget][field_body][0][value',
'default_value_php' => '',
],
],
],
'display_settings' => [
'label' => [
'format' => 'above',
'exclude' => 0,
],
'teaser' => [
'format' => 'default',
'exclude' => 0,
],
'full' => [
'format' => 'default',
'exclude' => 0,
],
],
],
];
// The source data.
$tests[0]['source_data']['content_node_field_instance'] = array_map(function (array $row) {
$row['widget_settings'] = serialize($row['widget_settings']);
$row['display_settings'] = serialize($row['display_settings']);
$row['global_settings'] = serialize($row['global_settings']);
return $row;
}, $tests[0]['expected_data']);
$tests[0]['source_data']['content_node_field'] = [
[
'field_name' => 'field_body',
'required' => 1,
'type' => 'text',
'active' => 1,
'global_settings' => serialize([]),
],
];
return $tests;
}