diff --git a/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php b/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php index 2d08efc6fc9..06a4bbdd429 100644 --- a/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php +++ b/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php @@ -63,6 +63,13 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TR throw new \Exception('Oh oh, bananas in the instruments.'); } + if (\Drupal::state()->get('error_service_test.disable_final_exception_subscriber')) { + // Prevent the final exception subscriber from catching errors. + /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */ + $event_dispatcher = \Drupal::service('event_dispatcher'); + $event_dispatcher->removeSubscriber(\Drupal::service('exception.final')); + } + if (\Drupal::state()->get('error_service_test.break_logger')) { throw new \Exception('Deforestation'); } diff --git a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php index b03e000b48c..a643371aea6 100644 --- a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +++ b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php @@ -159,6 +159,8 @@ public function testMissingDependencyCustomErrorHandler() { $settings_php .= "\$settings['teapots'] = TRUE;\n"; file_put_contents($settings_filename, $settings_php); + \Drupal::state()->set('error_service_test.disable_final_exception_subscriber', TRUE); + $this->drupalGet('broken-service-class'); $this->assertSession()->statusCodeEquals(418); $this->assertSession()->responseContains('Oh oh, flying teapots');