You are here

public function PluginBaseTest::providerTestSetOptionDefault in Drupal 8

Same name and namespace in other branches
  1. 9 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 224

Class

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

Namespace

Drupal\Tests\views\Unit

Code

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