function VariableTest::providerTestExport
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerTestExport()
- 10 core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerTestExport()
- 11.x core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerTestExport()
Data provider for testExport().
Return value
array An array containing:
- The expected export string.
- The variable to export.
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ VariableTest.php, line 103
Class
- VariableTest
- Test variable export functionality in Variable component.
Namespace
Drupal\Tests\Component\UtilityCode
public function providerTestExport() {
return [
// Array.
[
'array()',
[],
],
[
// non-associative.
"array(\n 1,\n 2,\n 3,\n 4,\n)",
[
1,
2,
3,
4,
],
],
[
// associative.
"array(\n 'a' => 1,\n)",
[
'a' => 1,
],
],
// Bool.
[
'TRUE',
TRUE,
],
[
'FALSE',
FALSE,
],
// Strings.
[
"'string'",
'string',
],
[
'"\\n\\r\\t"',
"\n\r\t",
],
[
// 2 backslashes. \\
"'\\'",
'\\',
],
[
// Double-quote "
"'\"'",
"\"",
],
[
// Single-quote '
'"\'"',
"'",
],
[
// Quotes with $ symbols.
'"\\$settings[\'foo\']"',
'$settings[\'foo\']',
],
// Object.
[
// A stdClass object.
'(object) array()',
new \stdClass(),
],
[
// A not-stdClass object. Since PHP 8.2 exported namespace is prefixed,
// see https://github.com/php/php-src/pull/8233 for reasons.
(PHP_VERSION_ID >= 80200 ? '\\' : '') . "Drupal\\Tests\\Component\\Utility\\StubVariableTestClass::__set_state(array(\n))",
new StubVariableTestClass(),
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.