function VariableTest::providerCallableToString

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerCallableToString()
  2. 11.x core/tests/Drupal/Tests/Component/Utility/VariableTest.php \Drupal\Tests\Component\Utility\VariableTest::providerCallableToString()

Data provider for testCallableToString().

Return value

array[] Sets of arguments to pass to the test method.

File

core/tests/Drupal/Tests/Component/Utility/VariableTest.php, line 26

Class

VariableTest
Test variable export functionality in Variable component.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerCallableToString() : array {
  $mock = VariableTestMock::class;
  return [
    'string' => [
      "{$mock}::fake",
      "{$mock}::fake",
    ],
    'static method as array' => [
      [
        $mock,
        'fake',
      ],
      "{$mock}::fake",
    ],
    'closure' => [
      function () {
        return NULL;
      },
      '[closure]',
    ],
    'object method' => [
      [
        new VariableTestMock(),
        'fake',
      ],
      "{$mock}::fake",
    ],
    'service method' => [
      'fake_service:method',
      'fake_service:method',
    ],
    'single-item array' => [
      [
        'some_function',
      ],
      'some_function',
    ],
    'empty array' => [
      [],
      '[unknown]',
    ],
    'object' => [
      new \stdClass(),
      '[unknown]',
    ],
    'definitely not callable' => [
      TRUE,
      '[unknown]',
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.