Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / media / tests / src / Functional / MediaTemplateSuggestionsTest.php
1 <?php
2
3 namespace Drupal\Tests\media\Functional;
4
5 use Drupal\media\Entity\Media;
6
7 /**
8  * Tests media template suggestions.
9  *
10  * @group media
11  */
12 class MediaTemplateSuggestionsTest extends MediaFunctionalTestBase {
13
14   /**
15    * Modules to install.
16    *
17    * @var array
18    */
19   public static $modules = ['media'];
20
21   /**
22    * Tests template suggestions from media_theme_suggestions_media().
23    */
24   public function testMediaThemeHookSuggestions() {
25     $media_type = $this->createMediaType('test', [
26       'queue_thumbnail_downloads' => FALSE,
27     ]);
28
29     // Create media item to be rendered.
30     $media = Media::create([
31       'bundle' => $media_type->id(),
32       'name' => 'Unnamed',
33     ]);
34     $media->save();
35     $view_mode = 'full';
36
37     // Simulate theming of the media item.
38     $build = \Drupal::entityTypeManager()->getViewBuilder('media')->view($media, $view_mode);
39
40     $variables['elements'] = $build;
41     $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_media', [$variables]);
42     $this->assertSame($suggestions, ['media__full', 'media__' . $media_type->id(), 'media__' . $media_type->id() . '__full', 'media__source_' . $media_type->getSource()->getPluginId()], 'Found expected media suggestions.');
43   }
44
45 }