You are here

public function VariableTest::providerTestExport in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerTestExport()
  2. 10 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 31
Contains \Drupal\Tests\Component\Utility\VariableTest.

Class

VariableTest
Test variable export functionality in Variable component.

Namespace

Drupal\Tests\Component\Utility

Code

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.
      "Drupal\\Tests\\Component\\Utility\\StubVariableTestClass::__set_state(array(\n))",
      new StubVariableTestClass(),
    ],
  ];
}