function PluginBaseTest::providerTestGetAvailableGlobalTokens

Same name and namespace in other branches
  1. main core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest::providerTestGetAvailableGlobalTokens()

Data provider for testGetAvailableGlobalTokens().

Return value

array

  • An associative array of token information.
  • An array of additional token types.
  • The expected tokens.

File

core/modules/views/tests/src/Unit/PluginBaseTest.php, line 67

Class

PluginBaseTest
Tests Drupal\views\Plugin\views\PluginBase.

Namespace

Drupal\Tests\views\Unit

Code

public static function providerTestGetAvailableGlobalTokens() : array {
  return [
    '0 global, 0 added' => [
      [
        'tokens' => [],
      ],
      [],
      [],
    ],
    '0 global, 1 added' => [
      [
        'tokens' => [],
      ],
      [
        'date',
      ],
      [],
    ],
    '1 global, 1 added, same' => [
      [
        'tokens' => [
          'date' => 'bar',
        ],
      ],
      [
        'date',
      ],
      [
        'date' => 'bar',
      ],
    ],
    '1 global, 0 added' => [
      [
        'tokens' => [
          'site' => 'foo',
        ],
      ],
      [],
      [
        'site' => 'foo',
      ],
    ],
    '1 global, 1 added' => [
      [
        'tokens' => [
          'site' => 'foo',
        ],
      ],
      [
        'date',
      ],
      [
        'site' => 'foo',
      ],
    ],
    '2 global, 1 added' => [
      [
        'tokens' => [
          'site' => 'foo',
          'date' => 'bar',
        ],
      ],
      [
        'date',
      ],
      [
        'site' => 'foo',
        'date' => 'bar',
      ],
    ],
    '3 global, 0 added' => [
      [
        'tokens' => [
          'site' => 'foo',
          'view' => 'baz',
          'date' => 'bar',
        ],
      ],
      [],
      [
        'site' => 'foo',
        'view' => 'baz',
      ],
    ],
    '3 global, 1 added' => [
      [
        'tokens' => [
          'site' => 'foo',
          'view' => 'baz',
          'date' => 'bar',
        ],
      ],
      [
        'date',
      ],
      [
        'site' => 'foo',
        'view' => 'baz',
        'date' => 'bar',
      ],
    ],
  ];
}

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