You are here

public function ThemeEventTest::testThemeEventWithAddNewThemesPathException in Hook Event Dispatcher 3.x

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

ThemeEvent with addNewThemes test.

File

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

Class

ThemeEventTest
Class ThemeEventTest.

Namespace

Drupal\Tests\core_event_dispatcher\Unit\Theme

Code

public function testThemeEventWithAddNewThemesPathException() : void {
  $newThemes = [
    'some_custom__hook_theme' => [
      'variables' => [
        'custom_variable' => NULL,
      ],
    ],
  ];
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::THEME => static function (ThemeEvent $event) use ($newThemes) {
      $event
        ->addNewThemes($newThemes);
    },
  ]);
  $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([]);
}