function PluginBaseTest::providerTestSetOptionDefault

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestSetOptionDefault()
  2. 8.9.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestSetOptionDefault()
  3. 11.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestSetOptionDefault()

Data provider for testSetOptionDefault().

Return value

array

File

core/modules/views/tests/src/Unit/PluginBaseTest.php, line 226

Class

PluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\PluginBase @group views

Namespace

Drupal\Tests\views\Unit

Code

public static function providerTestSetOptionDefault() {
    $test_parameters = [];
    // No definition should change anything on the storage.
    $test_parameters[] = [
        'storage' => [],
        'definition' => [],
        'expected' => [],
    ];
    // Set a single definition, which should be picked up.
    $test_parameters[] = [
        'storage' => [],
        'definition' => [
            'key' => [
                'default' => 'value',
            ],
        ],
        'expected' => [
            'key' => 'value',
        ],
    ];
    // Set multiple keys, all should be picked up.
    $test_parameters[] = [
        'storage' => [],
        'definition' => [
            'key' => [
                'default' => 'value',
            ],
            'key2' => [
                'default' => 'value2',
            ],
            'key3' => [
                'default' => 'value3',
            ],
        ],
        'expected' => [
            'key' => 'value',
            'key2' => 'value2',
            'key3' => 'value3',
        ],
    ];
    // Setup a definition with multiple levels.
    $test_parameters[] = [
        'storage' => [],
        'definition' => [
            'key' => [
                'default' => 'value',
            ],
            'key2' => [
                'contains' => [
                    'key2:1' => [
                        'default' => 'value2:1',
                    ],
                    'key2:2' => [
                        'default' => 'value2:2',
                    ],
                ],
            ],
        ],
        'expected' => [
            'key' => 'value',
            'key2' => [
                'key2:1' => 'value2:1',
                'key2:2' => 'value2:2',
            ],
        ],
    ];
    return $test_parameters;
}

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