function FieldTest::providerSource

Same name in this branch
  1. 9 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldTest::providerSource()
Same name and namespace in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldTest::providerSource()
  2. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldTest::providerSource()
  3. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldTest::providerSource()
  4. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldTest::providerSource()
  5. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldTest::providerSource()
  6. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldTest::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

File

core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php, line 23

Class

FieldTest
Tests D6 field source plugin.

Namespace

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

Code

public function providerSource() {
    $tests = [
        [
            'source_data' => [],
            'expected_data' => [],
        ],
    ];
    // The expected results.
    $tests[0]['expected_data'] = [
        [
            'field_name' => 'field_body',
            'type' => 'text',
            'global_settings' => [
                'text_processing' => 0,
                'max_length' => '',
                'allowed_values' => '',
                'allowed_values_php' => '',
            ],
            'required' => 0,
            'multiple' => 0,
            'db_storage' => 1,
            'module' => 'text',
            'db_columns' => [
                'value' => [
                    'type' => 'text',
                    'size' => 'big',
                    'not null' => '',
                    'sortable' => 1,
                    'views' => 1,
                ],
            ],
            'active' => 1,
            'locked' => 0,
        ],
    ];
    // The source data.
    $tests[0]['source_data']['content_node_field'] = array_map(function (array $row) {
        $row['global_settings'] = serialize($row['global_settings']);
        $row['db_columns'] = serialize($row['db_columns']);
        return $row;
    }, $tests[0]['expected_data']);
    $tests[0]['source_data']['content_node_field_instance'] = [
        [
            'widget_type' => 'text_textarea',
            'field_name' => 'field_body',
        ],
    ];
    return $tests;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.