You are here

public function ThemeSuggestionsAlterEventTest::testThemeSuggestionsAlterIdEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/core_event_dispatcher/tests/src/Unit/Theme/ThemeSuggestionsAlterEventTest.php \Drupal\Tests\core_event_dispatcher\Unit\Theme\ThemeSuggestionsAlterEventTest::testThemeSuggestionsAlterIdEvent()

Tests the ThemeSuggestionsAlterIdEvent.

File

modules/core_event_dispatcher/tests/src/Unit/Theme/ThemeSuggestionsAlterEventTest.php, line 71

Class

ThemeSuggestionsAlterEventTest
Class ThemeSuggestionsAlterEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Theme

Code

public function testThemeSuggestionsAlterIdEvent() : void {
  $this->manager
    ->setMaxEventCount(2);
  $suggestions = [
    'container_theme_function_1',
    'container_theme_function_2',
    'container_theme_function_3',
  ];
  $variables = [
    'content' => 'test',
  ];
  $hook = 'container';
  core_event_dispatcher_theme_suggestions_alter($suggestions, $variables, $hook);

  /** @var \Drupal\core_event_dispatcher\Event\Theme\ThemeSuggestionsAlterIdEvent $event */
  $event = $this->manager
    ->getRegisteredEvent('hook_event_dispatcher.theme.suggestions_' . $hook . '_alter');
  self::assertEquals($suggestions, $event
    ->getSuggestions());
  self::assertEquals($variables, $event
    ->getVariables());
}