You are here

public function CacheContextsManagerTest::validateTokensProvider in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::validateTokensProvider()

Provides a list of cache context token arrays.

Return value

array

File

core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php, line 178
Contains \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest.

Class

CacheContextsManagerTest
@coversDefaultClass \Drupal\Core\Cache\Context\CacheContextsManager @group Cache

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function validateTokensProvider() {
  return [
    [
      [],
      FALSE,
    ],
    [
      [
        'foo',
      ],
      FALSE,
    ],
    [
      [
        'foo',
        'foo.bar',
      ],
      FALSE,
    ],
    [
      [
        'foo',
        'baz:llama',
      ],
      FALSE,
    ],
    // Invalid.
    [
      [
        FALSE,
      ],
      'Cache contexts must be strings, boolean given.',
    ],
    [
      [
        TRUE,
      ],
      'Cache contexts must be strings, boolean given.',
    ],
    [
      [
        'foo',
        FALSE,
      ],
      'Cache contexts must be strings, boolean given.',
    ],
    [
      [
        NULL,
      ],
      'Cache contexts must be strings, NULL given.',
    ],
    [
      [
        'foo',
        NULL,
      ],
      'Cache contexts must be strings, NULL given.',
    ],
    [
      [
        1337,
      ],
      'Cache contexts must be strings, integer given.',
    ],
    [
      [
        'foo',
        1337,
      ],
      'Cache contexts must be strings, integer given.',
    ],
    [
      [
        3.14,
      ],
      'Cache contexts must be strings, double given.',
    ],
    [
      [
        'foo',
        3.14,
      ],
      'Cache contexts must be strings, double given.',
    ],
    [
      [
        [],
      ],
      'Cache contexts must be strings, array given.',
    ],
    [
      [
        'foo',
        [],
      ],
      'Cache contexts must be strings, array given.',
    ],
    [
      [
        'foo',
        [
          'bar',
        ],
      ],
      'Cache contexts must be strings, array given.',
    ],
    [
      [
        new \stdClass(),
      ],
      'Cache contexts must be strings, object given.',
    ],
    [
      [
        'foo',
        new \stdClass(),
      ],
      'Cache contexts must be strings, object given.',
    ],
    // Non-existing.
    [
      [
        'foo.bar',
        'qux',
      ],
      '"qux" is not a valid cache context ID.',
    ],
    [
      [
        'qux',
        'baz',
      ],
      '"qux" is not a valid cache context ID.',
    ],
  ];
}