public function PluginBaseTest::providerTestUnpackOptions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 80 - Contains \Drupal\Tests\views\Unit\PluginBaseTest.
Class
- PluginBaseTest
- @coversDefaultClass \Drupal\views\Plugin\views\PluginBase @group views
Namespace
Drupal\Tests\views\UnitCode
public function providerTestUnpackOptions() {
$test_parameters = array();
// Set a storage but no value, so the storage value should be kept.
$test_parameters[] = array(
'storage' => array(
'key' => 'value',
),
'options' => array(),
'definition' => array(
'key' => array(
'default' => 'value2',
),
),
'expected' => array(
'key' => 'value',
),
);
// Set a storage and a option value, so the option value should be kept.
$test_parameters[] = array(
'storage' => array(
'key' => 'value',
),
'options' => array(
'key' => 'value2',
),
'definition' => array(
'key' => array(
'default' => 'value3',
),
),
'expected' => array(
'key' => 'value2',
),
'',
);
// Set no storage but an options value, so the options value should be kept.
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key' => 'value',
),
'definition' => array(
'key' => array(
'default' => 'value2',
),
),
'expected' => array(
'key' => 'value',
),
);
// Set additional options, which aren't part of the definition, so they
// should be ignored if all is set.
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key' => 'value',
'key2' => 'value2',
),
'definition' => array(
'key' => array(
'default' => 'value2',
),
),
'expected' => array(
'key' => 'value',
),
);
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key' => 'value',
'key2' => 'value2',
),
'definition' => array(
'key' => array(
'default' => 'value2',
),
),
'expected' => array(
'key' => 'value',
'key2' => 'value2',
),
'all' => TRUE,
);
// Provide multiple options with their corresponding definition.
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key' => 'value',
'key2' => 'value2',
),
'definition' => array(
'key' => array(
'default' => 'value2',
),
'key2' => array(
'default' => 'value3',
),
),
'expected' => array(
'key' => 'value',
'key2' => 'value2',
),
);
// Set a complex definition structure with a zero and a one level structure.
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key0' => 'value',
'key1' => array(
'key1:1' => 'value1',
'key1:2' => 'value2',
),
),
'definition' => array(
'key0' => array(
'default' => 'value0',
),
'key1' => array(
'contains' => array(
'key1:1' => array(
'default' => 'value1:1',
),
),
),
),
'expected' => array(
'key0' => 'value',
'key1' => array(
'key1:1' => 'value1',
),
),
);
// Setup a two level structure.
$test_parameters[] = array(
'storage' => array(),
'options' => array(
'key2' => array(
'key2:1' => array(
'key2:1:1' => 'value0',
'key2:1:2' => array(
'key2:1:2:1' => 'value1',
),
),
),
),
'definition' => array(
'key2' => array(
'contains' => array(
'key2:1' => array(
'contains' => array(
'key2:1:1' => array(
'default' => 'value2:1:2:1',
),
'key2:1:2' => array(
'contains' => array(
'key2:1:2:1' => array(
'default' => 'value2:1:2:1',
),
),
),
),
),
),
),
),
'expected' => array(
'key2' => array(
'key2:1' => array(
'key2:1:1' => 'value0',
'key2:1:2' => array(
'key2:1:2:1' => 'value1',
),
),
),
),
);
return $test_parameters;
}