You are here

public function ThemeEventTest::testThemeEventWithAddNewThemeWithPathException in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/core_event_dispatcher/tests/src/Unit/Theme/ThemeEventTest.php \Drupal\Tests\core_event_dispatcher\Unit\Theme\ThemeEventTest::testThemeEventWithAddNewThemeWithPathException()

ThemeEvent with addNewTheme test.

File

modules/core_event_dispatcher/tests/src/Unit/Theme/ThemeEventTest.php, line 146

Class

ThemeEventTest
Class ThemeEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Theme

Code

public function testThemeEventWithAddNewThemeWithPathException() : void {
  $themeHook = 'extra_theme__hook';
  $information = [
    'test' => 'extra_theme_information',
  ];
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::THEME => static function (ThemeEvent $event) use ($themeHook, $information) {
      $event
        ->addNewTheme($themeHook, $information);
    },
  ]);
  $this
    ->expectException(RuntimeException::class);
  $this
    ->expectExceptionMessage('Missing path in the information array. ThemeEvent needs the path to be set manually, to have a proper default theme implementation. See \\hook_theme() for more information.');
  core_event_dispatcher_theme([]);
}