function RendererTest::providerTestAddCacheableDependency

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::providerTestAddCacheableDependency()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::providerTestAddCacheableDependency()
  3. 10 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::providerTestAddCacheableDependency()

File

core/tests/Drupal/Tests/Core/Render/RendererTest.php, line 1001

Class

RendererTest
@coversDefaultClass \Drupal\Core\Render\Renderer @group Render

Namespace

Drupal\Tests\Core\Render

Code

public static function providerTestAddCacheableDependency() {
    return [
        // Empty render array, typical default cacheability.
[
            [],
            new TestCacheableDependency([], [], Cache::PERMANENT),
            [
                '#cache' => [
                    'contexts' => [],
                    'tags' => [],
                    'max-age' => Cache::PERMANENT,
                ],
            ],
        ],
        // Empty render array, some cacheability.
[
            [],
            new TestCacheableDependency([
                'user.roles',
            ], [
                'foo',
            ], Cache::PERMANENT),
            [
                '#cache' => [
                    'contexts' => [
                        'user.roles',
                    ],
                    'tags' => [
                        'foo',
                    ],
                    'max-age' => Cache::PERMANENT,
                ],
            ],
        ],
        // Cacheable render array, some cacheability.
[
            [
                '#cache' => [
                    'contexts' => [
                        'theme',
                    ],
                    'tags' => [
                        'bar',
                    ],
                    'max-age' => 600,
                ],
            ],
            new TestCacheableDependency([
                'user.roles',
            ], [
                'foo',
            ], Cache::PERMANENT),
            [
                '#cache' => [
                    'contexts' => [
                        'theme',
                        'user.roles',
                    ],
                    'tags' => [
                        'bar',
                        'foo',
                    ],
                    'max-age' => 600,
                ],
            ],
        ],
        // Cacheable render array, no cacheability.
[
            [
                '#cache' => [
                    'contexts' => [
                        'theme',
                    ],
                    'tags' => [
                        'bar',
                    ],
                    'max-age' => 600,
                ],
            ],
            new \stdClass(),
            [
                '#cache' => [
                    'contexts' => [
                        'theme',
                    ],
                    'tags' => [
                        'bar',
                    ],
                    'max-age' => 0,
                ],
            ],
        ],
    ];
}

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