You are here

public function VariableTest::providerCallableToString in Drupal 9

Same name and namespace in other branches
  1. 10 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 35
Contains \Drupal\Tests\Component\Utility\VariableTest.

Class

VariableTest
Test variable export functionality in Variable component.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerCallableToString() : array {
  $self = static::class;
  return [
    'string' => [
      "{$self}::fake",
      "{$self}::fake",
    ],
    'static method as array' => [
      [
        $self,
        'fake',
      ],
      "{$self}::fake",
    ],
    'closure' => [
      function () {
        return NULL;
      },
      '[closure]',
    ],
    'object method' => [
      [
        new static(),
        'fake',
      ],
      "{$self}::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]',
    ],
  ];
}