function FieldInstanceTest::providerSource

Same name in this branch
  1. 9 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldInstanceTest::providerSource()
Same name in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldInstanceTest::providerSource()
  2. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldInstanceTest::providerSource()
  3. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldInstanceTest::providerSource()
  4. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldInstanceTest::providerSource()
  5. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d6\FieldInstanceTest::providerSource()
  6. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php \Drupal\Tests\field\Kernel\Plugin\migrate\source\d7\FieldInstanceTest::providerSource()

Overrides MigrateSourceTestBase::providerSource

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\d6

Code

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;
}

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