You are here

public function CacheableMetadataTest::providerTestCreateFromRenderArray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::providerTestCreateFromRenderArray()

Provides test data for createFromRenderArray().

Return value

array

File

core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php, line 154
Contains \Drupal\Tests\Core\Cache\CacheableMetadataTest.

Class

CacheableMetadataTest
@coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function providerTestCreateFromRenderArray() {
  $data = [];
  $empty_metadata = new CacheableMetadata();
  $nonempty_metadata = new CacheableMetadata();
  $nonempty_metadata
    ->setCacheContexts([
    'qux',
  ])
    ->setCacheTags([
    'foo:bar',
  ]);
  $empty_render_array = [];
  $nonempty_render_array = [
    '#cache' => [
      'contexts' => [
        'qux',
      ],
      'tags' => [
        'foo:bar',
      ],
      'max-age' => Cache::PERMANENT,
    ],
  ];
  $data[] = [
    $empty_render_array,
    $empty_metadata,
  ];
  $data[] = [
    $nonempty_render_array,
    $nonempty_metadata,
  ];
  return $data;
}