function CacheContextsManagerTest::providerTestOptimizeTokens

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::providerTestOptimizeTokens()
  2. 10 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::providerTestOptimizeTokens()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::providerTestOptimizeTokens()

Provides a list of context token sets.

File

core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php, line 50

Class

CacheContextsManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21Context%21CacheContextsManager.php/class/CacheContextsManager/8.9.x" title="Converts cache context tokens into cache keys." class="local">\Drupal\Core\Cache\Context\CacheContextsManager</a> @group Cache

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function providerTestOptimizeTokens() {
    return [
        [
            [
                'a',
                'x',
            ],
            [
                'a',
                'x',
            ],
        ],
        [
            [
                'a.b',
                'x',
            ],
            [
                'a.b',
                'x',
            ],
        ],
        // Direct ancestor, single-level hierarchy.
[
            [
                'a',
                'a.b',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b',
                'a',
            ],
            [
                'a',
            ],
        ],
        // Direct ancestor, multi-level hierarchy.
[
            [
                'a.b',
                'a.b.c',
            ],
            [
                'a.b',
            ],
        ],
        [
            [
                'a.b.c',
                'a.b',
            ],
            [
                'a.b',
            ],
        ],
        // Indirect ancestor.
[
            [
                'a',
                'a.b.c',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b.c',
                'a',
            ],
            [
                'a',
            ],
        ],
        // Direct & indirect ancestors.
[
            [
                'a',
                'a.b',
                'a.b.c',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a',
                'a.b.c',
                'a.b',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b',
                'a',
                'a.b.c',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b',
                'a.b.c',
                'a',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b.c',
                'a.b',
                'a',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b.c',
                'a',
                'a.b',
            ],
            [
                'a',
            ],
        ],
        // Using parameters.
[
            [
                'a',
                'a.b.c:foo',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b.c:foo',
                'a',
            ],
            [
                'a',
            ],
        ],
        [
            [
                'a.b.c:foo',
                'a.b.c',
            ],
            [
                'a.b.c',
            ],
        ],
        // max-age 0 is treated as non-optimizable.
[
            [
                'a.b.no-optimize',
                'a.b',
                'a',
            ],
            [
                'a.b.no-optimize',
                'a',
            ],
        ],
    ];
}

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