You are here

public function RendererTest::providerTestAddCacheableDependency in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::providerTestAddCacheableDependency()

File

core/tests/Drupal/Tests/Core/Render/RendererTest.php, line 790
Contains \Drupal\Tests\Core\Render\RendererTest.

Class

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

Namespace

Drupal\Tests\Core\Render

Code

public 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,
        ],
      ],
    ],
  ];
}