MediaTemplateSuggestionsTest.php in Drupal 10
File
core/modules/media/tests/src/Functional/MediaTemplateSuggestionsTest.php
View source
<?php
namespace Drupal\Tests\media\Functional;
use Drupal\media\Entity\Media;
class MediaTemplateSuggestionsTest extends MediaFunctionalTestBase {
protected static $modules = [
'media',
];
protected $defaultTheme = 'stark';
public function testMediaThemeHookSuggestions() {
$media_type = $this
->createMediaType('test', [
'queue_thumbnail_downloads' => FALSE,
]);
$media = Media::create([
'bundle' => $media_type
->id(),
'name' => 'Unnamed',
]);
$media
->save();
$view_mode = 'full';
$build = \Drupal::entityTypeManager()
->getViewBuilder('media')
->view($media, $view_mode);
$variables['elements'] = $build;
$suggestions = \Drupal::moduleHandler()
->invokeAll('theme_suggestions_media', [
$variables,
]);
$this
->assertSame($suggestions, [
'media__full',
'media__' . $media_type
->id(),
'media__' . $media_type
->id() . '__full',
'media__source_' . $media_type
->getSource()
->getPluginId(),
], 'Found expected media suggestions.');
}
}