public function CacheableMetadataTest::providerTestCreateFromObject in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::providerTestCreateFromObject()
- 9 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 184
Class
- CacheableMetadataTest
- @coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache
Namespace
Drupal\Tests\Core\CacheCode
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;
}