diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 412a7b3..afba2ff 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -295,7 +295,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // If any modules were newly installed, invoke hook_modules_installed(). if (!empty($modules_installed)) { - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->setRebuildNeeded(); $this->moduleHandler->invokeAll('modules_installed', array($modules_installed)); } @@ -437,7 +437,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $schema_store = \Drupal::keyValue('system.schema'); $schema_store->delete($module); } - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->setRebuildNeeded(); drupal_get_installed_schema_version(NULL, TRUE); // Let other modules react. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index db516af..c3f494a 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -45,13 +45,6 @@ class RouteBuilder implements RouteBuilderInterface, DestructableInterface { protected $dispatcher; /** - * The yaml discovery used to find all the .routing.yml files. - * - * @var \Drupal\Component\Discovery\YamlDiscovery - */ - protected $yamlDiscovery; - - /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface @@ -232,10 +225,8 @@ public function destruct() { * The defined routes, keyed by provider. */ protected function getRouteDefinitions() { - if (!isset($this->yamlDiscovery)) { - $this->yamlDiscovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); - } - return $this->yamlDiscovery->findAll(); + $discovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); + return $discovery->findAll(); } } diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index 6850fcb..677711e 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -126,7 +126,7 @@ public function resetActiveTheme() { /** * {@inheritdoc} */ - public function setActiveTheme(ActiveTheme $active_theme) { + public function setActiveTheme(ActiveTheme $active_theme = NULL) { $this->activeTheme = $active_theme; if ($active_theme) { $this->themeInitialization->loadActiveTheme($active_theme); diff --git a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php index fdc6334..96a1d42 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php @@ -64,7 +64,7 @@ public function resetActiveTheme(); * The new active theme. * @return $this */ - public function setActiveTheme(ActiveTheme $active_theme); + public function setActiveTheme(ActiveTheme $active_theme = NULL); /** * Passes alterable variables to specific $theme_TYPE_alter() implementations. diff --git a/core/modules/book/src/Tests/BookUninstallTest.php b/core/modules/book/src/Tests/BookUninstallTest.php index dbd4de5..5762366 100644 --- a/core/modules/book/src/Tests/BookUninstallTest.php +++ b/core/modules/book/src/Tests/BookUninstallTest.php @@ -23,14 +23,13 @@ class BookUninstallTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user', 'field', 'filter', 'text', 'entity_reference', 'node', 'book'); + public static $modules = array('user', 'field', 'filter', 'text', 'entity_reference', 'node', 'book'); /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('user'); $this->installEntitySchema('node'); $this->installSchema('book', array('book')); diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php index ab303b6..25558d3 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php @@ -44,7 +44,6 @@ protected function setUp() { // Install the Filter module. $this->installSchema('system', 'url_alias'); - $this->installSchema('system', 'router'); // Create text format, associate CKEditor. $filtered_html_format = entity_create('filter_format', array( diff --git a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php index ddfaf8f..3cb8ab0 100644 --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -29,7 +29,6 @@ class CommentStringIdEntitiesTest extends KernelTestBase { 'field_ui', 'entity', 'entity_test', - 'system', 'text', ); @@ -37,7 +36,6 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('comment'); $this->installSchema('comment', array('comment_entity_statistics')); - $this->installSchema('system', array('router')); // Create the comment body field storage. $this->installConfig(array('field')); } diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php index c530b96..f42d722 100644 --- a/core/modules/config/src/Tests/ConfigCRUDTest.php +++ b/core/modules/config/src/Tests/ConfigCRUDTest.php @@ -39,11 +39,6 @@ class ConfigCRUDTest extends KernelTestBase { */ public static $modules = array('system'); - protected function setUp() { - parent::setUp(); - $this->installSchema('system', 'router'); - } - /** * Tests CRUD operations. */ diff --git a/core/modules/config/src/Tests/DefaultConfigTest.php b/core/modules/config/src/Tests/DefaultConfigTest.php index 2d5412c..99ff07a 100644 --- a/core/modules/config/src/Tests/DefaultConfigTest.php +++ b/core/modules/config/src/Tests/DefaultConfigTest.php @@ -45,7 +45,6 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', 'router'); \Drupal::service('theme_handler')->install($this->themes); } diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 9cedc2d..ef0f476 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -26,7 +26,6 @@ class EntityDisplayTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('node'); $this->installConfig(array('field')); } diff --git a/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php index 3ceb5eb..6ee11e2 100644 --- a/core/modules/filter/src/Tests/FilterAPITest.php +++ b/core/modules/filter/src/Tests/FilterAPITest.php @@ -28,7 +28,6 @@ class FilterAPITest extends EntityUnitTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installConfig(array('system', 'filter')); } diff --git a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php index f6902e39..97fe51f 100644 --- a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php +++ b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php @@ -30,7 +30,6 @@ class NodeImportCreateTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('user'); // Set default storage backend. diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 497f085..b621140 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -352,10 +352,13 @@ protected function checkRequirements() { * Keyed array representing an assertion, as generated by assert(). * * @see self::assert() + * + * @return \Drupal\Core\Database\StatementInterface|int|null + * The message ID. */ protected function storeAssertion(array $assertion) { return self::getDatabaseConnection() - ->insert('simpletest') + ->insert('simpletest', ['return' => Database::RETURN_INSERT_ID]) ->fields($assertion) ->execute(); } @@ -398,7 +401,7 @@ protected function assert($status, $message = '', $group = 'Other', array $calle } // Creation assertion array that can be displayed while tests are running. - $this->assertions[] = $assertion = array( + $assertion = array( 'test_id' => $this->testId, 'test_class' => get_class($this), 'status' => $status, @@ -410,7 +413,9 @@ protected function assert($status, $message = '', $group = 'Other', array $calle ); // Store assertion for display after the test has completed. - $this->storeAssertion($assertion); + $message_id = $this->storeAssertion($assertion); + $assertion['message_id'] = $message_id; + $this->assertions[] = $assertion; // We do not use a ternary operator here to allow a breakpoint on // test failure. diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index 8d2382e..218d0b9 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -21,7 +21,7 @@ class KernelTestBaseTest extends KernelTestBase { * * @var array */ - public static $modules = array('entity_test', 'system'); + public static $modules = array('entity_test'); /** * {@inheritdoc} @@ -44,7 +44,6 @@ function simpletest_test_stub_settings_function() {} $original_container = $this->originalContainer; parent::setUp(); - $this->installSchema('system', array('router')); $this->assertNotIdentical(\Drupal::getContainer(), $original_container, 'KernelTestBase test creates a new container.'); } @@ -52,7 +51,7 @@ function simpletest_test_stub_settings_function() {} * Tests expected behavior of setUp(). */ function testSetUp() { - $modules = array('entity_test', 'system'); + $modules = array('entity_test'); $table = 'entity_test'; // Verify that specified $modules have been loaded. diff --git a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php index ea46747..f427ade 100644 --- a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php +++ b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php @@ -31,7 +31,6 @@ class FieldModuleUninstallValidatorTest extends EntityUnitTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', 'router'); $this->installSchema('user', 'users_data'); $this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager'); diff --git a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php index b831830..2a34c20 100644 --- a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php +++ b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php @@ -16,16 +16,6 @@ */ class ModuleImplementsAlterTest extends KernelTestBase { - public static $modules = array('system'); - - /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - $this->installSchema('system', array('router')); - } - /** * Tests hook_module_implements_alter() adding an implementation. * diff --git a/core/modules/system/src/Tests/Routing/RouterTest.php b/core/modules/system/src/Tests/Routing/RouterTest.php index 85e5e4b..92e9608 100644 --- a/core/modules/system/src/Tests/Routing/RouterTest.php +++ b/core/modules/system/src/Tests/Routing/RouterTest.php @@ -194,6 +194,7 @@ public function testControllerResolutionAjax() { */ public function testRouterUninstallInstall() { \Drupal::service('module_installer')->uninstall(array('router_test')); + \Drupal::service('router.builder')->rebuild(); try { \Drupal::service('router.route_provider')->getRouteByName('router_test.1'); $this->fail('Route was delete on uninstall.'); @@ -203,6 +204,7 @@ public function testRouterUninstallInstall() { } // Install the module again. \Drupal::service('module_installer')->install(array('router_test')); + \Drupal::service('router.builder')->rebuild(); $route = \Drupal::service('router.route_provider')->getRouteByName('router_test.1'); $this->assertNotNull($route, 'Route exists after module installation'); } diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php index 597a374..ec00d6e 100644 --- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php +++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php @@ -46,6 +46,11 @@ function testErrorHandler() { '%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()', '%file' => drupal_get_path('module', 'error_test') . '/error_test.module', ); + $fatal_error = array( + '%type' => 'Recoverable fatal error', + '%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()', + '!message' => 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in /Users/dawehner/www/d8/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 66 and defined', + ); // Set error reporting to display verbose notices. $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save(); @@ -56,6 +61,21 @@ function testErrorHandler() { $this->assertErrorMessage($error_user_notice); $this->assertRaw('
', 'Found pre element with backtrace class.');
 
+    // Set error reporting to display verbose notices.
+    $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
+    $this->drupalGet('error-test/generate-fatals');
+    $this->assertResponse(500, 'Received expected HTTP status code.');
+    $this->assertErrorMessage($fatal_error);
+    $this->assertRaw('
', 'Found pre element with backtrace class.');
+
+    // Remove the fatal error from the assertions, its wanted here.
+    foreach ($this->assertions as $key => $assertion) {
+      if ($assertion['message'] === 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in /Users/dawehner/www/d8/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 66 and defined') {
+        unset($this->assertions[$key]);
+        $this->deleteAssert($assertion['message_id']);
+      }
+    }
+
     // Set error reporting to collect notices.
     $config->set('error_level', ERROR_REPORTING_DISPLAY_ALL)->save();
     $this->drupalGet('error-test/generate-warnings');
diff --git a/core/modules/system/src/Tests/System/InfoAlterTest.php b/core/modules/system/src/Tests/System/InfoAlterTest.php
index 42f5041..02cdd17 100644
--- a/core/modules/system/src/Tests/System/InfoAlterTest.php
+++ b/core/modules/system/src/Tests/System/InfoAlterTest.php
@@ -19,14 +19,6 @@ class InfoAlterTest extends KernelTestBase {
   public static $modules = array('system');
 
   /**
-   * {@inheritdoc}
-   */
-  protected function setUp() {
-    parent::setUp();
-    $this->installSchema('system', array('router'));
-  }
-
-  /**
    * Tests that theme .info.yml data is rebuild after enabling a module.
    *
    * Tests that info data is rebuilt after a module that implements
diff --git a/core/modules/system/src/Tests/System/TrustedHostsTest.php b/core/modules/system/src/Tests/System/TrustedHostsTest.php
index 3719bd1..e54decc 100644
--- a/core/modules/system/src/Tests/System/TrustedHostsTest.php
+++ b/core/modules/system/src/Tests/System/TrustedHostsTest.php
@@ -69,6 +69,7 @@ public function testStatusPageWithConfiguration() {
    */
   public function testFakeRequests() {
     $this->container->get('module_installer')->install(['trusted_hosts_test']);
+    $this->container->get('router.builder')->rebuild();
 
     $host = $this->container->get('request_stack')->getCurrentRequest()->getHost();
     $settings['settings']['trusted_host_patterns'] = (object) array(
@@ -88,6 +89,7 @@ public function testFakeRequests() {
   public function testShortcut() {
     $this->container->get('module_installer')->install(['block', 'shortcut']);
     $this->rebuildContainer();
+    $this->container->get('router.builder')->rebuild();
 
     /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
     $entity_manager = $this->container->get('entity.manager');
diff --git a/core/modules/system/src/Tests/Theme/RegistryTest.php b/core/modules/system/src/Tests/Theme/RegistryTest.php
index 763372e..8872f10 100644
--- a/core/modules/system/src/Tests/Theme/RegistryTest.php
+++ b/core/modules/system/src/Tests/Theme/RegistryTest.php
@@ -28,15 +28,6 @@ class RegistryTest extends KernelTestBase {
   protected $profile = 'testing';
 
   /**
-   * {@inheritdoc}
-   */
-  protected function setUp() {
-     parent::setUp();
-
-     $this->installSchema('system', ['router']);
-  }
-
-  /**
    * Tests the behavior of the theme registry class.
    */
   function testRaceCondition() {
diff --git a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php
index 09d73e7..3ef48d0 100644
--- a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php
@@ -34,7 +34,6 @@ class ThemeSettingsTest extends KernelTestBase {
 
   protected function setUp() {
     parent::setUp();
-    $this->installSchema('system', array('router'));
     // Theme settings rely on System module's system.theme.global configuration.
     $this->installConfig(array('system'));
 
diff --git a/core/modules/system/tests/modules/error_test/error_test.routing.yml b/core/modules/system/tests/modules/error_test/error_test.routing.yml
index 141d71c..ad96152 100644
--- a/core/modules/system/tests/modules/error_test/error_test.routing.yml
+++ b/core/modules/system/tests/modules/error_test/error_test.routing.yml
@@ -5,6 +5,13 @@ error_test.generate_warnings:
   requirements:
     _access: 'TRUE'
 
+error_test.generate_fatals:
+  path: '/error-test/generate-fatals'
+  defaults:
+    _controller: '\Drupal\error_test\Controller\ErrorTestController::generateFatals'
+  requirements:
+    _access: 'TRUE'
+
 error_test.generate_warnings_with_report:
   path: '/error-test/generate-warnings-with-report'
   defaults:
diff --git a/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php b/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
index fe2430c..25ef1c5 100644
--- a/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
+++ b/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
@@ -57,6 +57,17 @@ public function generateWarnings($collect_errors = FALSE) {
   }
 
   /**
+   * Generate fatals to test the error handler.
+   */
+  public function generateFatals() {
+    $function = function(array $test) {
+    };
+
+    $function("test-string");
+    return [];
+  }
+
+  /**
    * Trigger an exception to test the exception handler.
    */
   public function triggerException() {
diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php
index 3ca1dc4..94e981d 100644
--- a/core/modules/tracker/src/Tests/TrackerTest.php
+++ b/core/modules/tracker/src/Tests/TrackerTest.php
@@ -347,6 +347,7 @@ function testTrackerCronIndexing() {
    */
   function testTrackerAdminUnpublish() {
     \Drupal::service('module_installer')->install(array('views'));
+    \Drupal::service('router.builder')->rebuild();
     $admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access'));
     $this->drupalLogin($admin_user);
 
diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php
index 029a66c..2ef966a 100644
--- a/core/modules/user/src/Tests/UserCancelTest.php
+++ b/core/modules/user/src/Tests/UserCancelTest.php
@@ -72,6 +72,7 @@ function testUserCancelWithoutPermission() {
    */
   public function testUserCancelChangePermission() {
     \Drupal::service('module_installer')->install(array('user_form_test'));
+    \Drupal::service('router.builder')->rebuild();
     $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
 
     // Create a regular user.
@@ -96,6 +97,7 @@ public function testUserCancelChangePermission() {
    */
   function testUserCancelUid1() {
     \Drupal::service('module_installer')->install(array('views'));
+    \Drupal::service('router.builder')->rebuild();
     // Update uid 1's name and password to we know it.
     $password = user_password();
     $account = array(
@@ -453,6 +455,7 @@ function testUserWithoutEmailCancelByAdmin() {
    */
   function testMassUserCancelByAdmin() {
     \Drupal::service('module_installer')->install(array('views'));
+    \Drupal::service('router.builder')->rebuild();
     $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
     // Enable account cancellation notification.
     $this->config('user.settings')->set('notify.status_canceled', TRUE)->save();
diff --git a/core/modules/views/src/Tests/Plugin/DisplayTest.php b/core/modules/views/src/Tests/Plugin/DisplayTest.php
index e224403..81bb1c2 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayTest.php
@@ -352,6 +352,7 @@ public function testOutputIsEmpty() {
    */
   public function testTranslationSetting() {
     \Drupal::service('module_installer')->install(['file']);
+    \Drupal::service('router.builder')->rebuild();
 
     // By default there should be no language settings.
     $this->checkTranslationSetting();
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
index b8f212f..36cd9cd 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
@@ -290,6 +290,13 @@ public function setYamlDiscovery(YamlDiscovery $yaml_discovery) {
     $this->yamlDiscovery = $yaml_discovery;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function getRouteDefinitions() {
+    return $this->yamlDiscovery->findAll();
+  }
+
 }
 
 /**