You are here

public function CacheableMetadataTest::providerTestCreateFromObject 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::providerTestCreateFromObject()

Provides test data for createFromObject().

Return value

array

File

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

Class

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

Namespace

Drupal\Tests\Core\Cache

Code

public function providerTestCreateFromObject() {
  $data = [];
  $empty_metadata = new CacheableMetadata();
  $nonempty_metadata = new CacheableMetadata();
  $nonempty_metadata
    ->setCacheContexts([
    'qux',
  ])
    ->setCacheTags([
    'foo:bar',
  ])
    ->setCacheMaxAge(600);
  $uncacheable_metadata = new CacheableMetadata();
  $uncacheable_metadata
    ->setCacheMaxAge(0);
  $empty_cacheable_object = new TestCacheableDependency([], [], Cache::PERMANENT);
  $nonempty_cacheable_object = new TestCacheableDependency([
    'qux',
  ], [
    'foo:bar',
  ], 600);
  $uncacheable_object = new \stdClass();
  $data[] = [
    $empty_cacheable_object,
    $empty_metadata,
  ];
  $data[] = [
    $nonempty_cacheable_object,
    $nonempty_metadata,
  ];
  $data[] = [
    $uncacheable_object,
    $uncacheable_metadata,
  ];
  return $data;
}