function PluginBaseTest::providerTestUnpackOptions
Same name in other branches
- 8.9.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestUnpackOptions()
- 10 core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestUnpackOptions()
- 11.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestUnpackOptions()
Data provider for testUnpackOptions().
Return value
array
File
-
core/
modules/ views/ tests/ src/ Unit/ PluginBaseTest.php, line 75
Class
- PluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\PluginBase @group views
Namespace
Drupal\Tests\views\UnitCode
public function providerTestUnpackOptions() {
$test_parameters = [];
// Set a storage but no value, so the storage value should be kept.
$test_parameters[] = [
'storage' => [
'key' => 'value',
],
'options' => [],
'definition' => [
'key' => [
'default' => 'value2',
],
],
'expected' => [
'key' => 'value',
],
];
// Set a storage and an option value, so the option value should be kept.
$test_parameters[] = [
'storage' => [
'key' => 'value',
],
'options' => [
'key' => 'value2',
],
'definition' => [
'key' => [
'default' => 'value3',
],
],
'expected' => [
'key' => 'value2',
],
'',
];
// Set no storage but an options value, so the options value should be kept.
$test_parameters[] = [
'storage' => [],
'options' => [
'key' => 'value',
],
'definition' => [
'key' => [
'default' => 'value2',
],
],
'expected' => [
'key' => 'value',
],
];
// Set additional options, which aren't part of the definition, so they
// should be ignored if all is set.
$test_parameters[] = [
'storage' => [],
'options' => [
'key' => 'value',
'key2' => 'value2',
],
'definition' => [
'key' => [
'default' => 'value2',
],
],
'expected' => [
'key' => 'value',
],
];
$test_parameters[] = [
'storage' => [],
'options' => [
'key' => 'value',
'key2' => 'value2',
],
'definition' => [
'key' => [
'default' => 'value2',
],
],
'expected' => [
'key' => 'value',
'key2' => 'value2',
],
'all' => TRUE,
];
// Provide multiple options with their corresponding definition.
$test_parameters[] = [
'storage' => [],
'options' => [
'key' => 'value',
'key2' => 'value2',
],
'definition' => [
'key' => [
'default' => 'value2',
],
'key2' => [
'default' => 'value3',
],
],
'expected' => [
'key' => 'value',
'key2' => 'value2',
],
];
// Set a complex definition structure with a zero and a one level structure.
$test_parameters[] = [
'storage' => [],
'options' => [
'key0' => 'value',
'key1' => [
'key1:1' => 'value1',
'key1:2' => 'value2',
],
],
'definition' => [
'key0' => [
'default' => 'value0',
],
'key1' => [
'contains' => [
'key1:1' => [
'default' => 'value1:1',
],
],
],
],
'expected' => [
'key0' => 'value',
'key1' => [
'key1:1' => 'value1',
],
],
];
// Setup a two level structure.
$test_parameters[] = [
'storage' => [],
'options' => [
'key2' => [
'key2:1' => [
'key2:1:1' => 'value0',
'key2:1:2' => [
'key2:1:2:1' => 'value1',
],
],
],
],
'definition' => [
'key2' => [
'contains' => [
'key2:1' => [
'contains' => [
'key2:1:1' => [
'default' => 'value2:1:2:1',
],
'key2:1:2' => [
'contains' => [
'key2:1:2:1' => [
'default' => 'value2:1:2:1',
],
],
],
],
],
],
],
],
'expected' => [
'key2' => [
'key2:1' => [
'key2:1:1' => 'value0',
'key2:1:2' => [
'key2:1:2:1' => 'value1',
],
],
],
],
];
return $test_parameters;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.