You are here

public function VariableTest::providerTestExport in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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.
    array(
      'array()',
      array(),
    ),
    array(
      // non-associative.
      "array(\n  1,\n  2,\n  3,\n  4,\n)",
      array(
        1,
        2,
        3,
        4,
      ),
    ),
    array(
      // associative.
      "array(\n  'a' => 1,\n)",
      array(
        'a' => 1,
      ),
    ),
    // Bool.
    array(
      'TRUE',
      TRUE,
    ),
    array(
      'FALSE',
      FALSE,
    ),
    // Strings.
    array(
      "'string'",
      'string',
    ),
    array(
      '"\\n\\r\\t"',
      "\n\r\t",
    ),
    array(
      // 2 backslashes. \\
      "'\\'",
      '\\',
    ),
    array(
      // Double-quote "
      "'\"'",
      "\"",
    ),
    array(
      // Single-quote '
      '"\'"',
      "'",
    ),
    array(
      // Quotes with $ symbols.
      '"\\$settings[\'foo\']"',
      '$settings[\'foo\']',
    ),
    // Object.
    array(
      // A stdClass object.
      '(object) array()',
      new \stdClass(),
    ),
    array(
      // A not-stdClass object.
      "Drupal\\Tests\\Component\\Utility\\StubVariableTestClass::__set_state(array(\n))",
      new StubVariableTestClass(),
    ),
  );
}