X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fcore%2Fmodules%2Fmedia%2Ftests%2Fsrc%2FFunctional%2FMediaCacheTagsTest.php;fp=web%2Fcore%2Fmodules%2Fmedia%2Ftests%2Fsrc%2FFunctional%2FMediaCacheTagsTest.php;h=8da814b9d3a195dd5f389c0e6efb60cd367d4f6b;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/media/tests/src/Functional/MediaCacheTagsTest.php b/web/core/modules/media/tests/src/Functional/MediaCacheTagsTest.php new file mode 100644 index 000000000..8da814b9d --- /dev/null +++ b/web/core/modules/media/tests/src/Functional/MediaCacheTagsTest.php @@ -0,0 +1,62 @@ +createMediaType(); + + // Create a media item. + $media = Media::create([ + 'bundle' => $mediaType->id(), + 'name' => 'Unnamed', + ]); + $media->save(); + + return $media; + } + + /** + * {@inheritdoc} + */ + protected function getAdditionalCacheContextsForEntity(EntityInterface $media) { + return ['timezone']; + } + + /** + * {@inheritdoc} + */ + protected function getAdditionalCacheTagsForEntity(EntityInterface $media) { + // Each media item must have an author and a thumbnail. + return [ + 'user:' . $media->getOwnerId(), + 'config:image.style.thumbnail', + 'file:' . $media->get('thumbnail')->entity->id(), + ]; + } + +}