diff --git a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php index ee274e0..a0ca5f2 100644 --- a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php @@ -57,9 +57,6 @@ protected function setUp() { $this->installSchema('comment', array('comment_entity_statistics')); $this->installConfig(array('system', 'filter', 'comment')); - // Comment rendering generates links, so build the router. - $this->installSchema('system', array('router')); - // Set up a field, so that the entity that'll be referenced bubbles up a // cache tag when rendering it entirely. $this->addDefaultCommentField('entity_test', 'entity_test'); diff --git a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php index ac2fe56..93ee0c0 100644 --- a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php +++ b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php @@ -39,7 +39,6 @@ protected function setUp() { $this->installEntitySchema('node'); $this->installEntitySchema('comment'); $this->installSchema('comment', ['comment_entity_statistics']); - $this->installSchema('system', ['router']); $this->installConfig(['comment']); $this->migrateContent(); diff --git a/core/modules/editor/src/Tests/EditorImageDialogTest.php b/core/modules/editor/src/Tests/EditorImageDialogTest.php index cd92153..efd79c3 100644 --- a/core/modules/editor/src/Tests/EditorImageDialogTest.php +++ b/core/modules/editor/src/Tests/EditorImageDialogTest.php @@ -41,7 +41,7 @@ class EditorImageDialogTest extends EntityUnitTestBase { protected function setUp() { parent::setUp(); $this->installEntitySchema('file'); - $this->installSchema('system', ['router', 'key_value_expire']); + $this->installSchema('system', 'key_value_expire'); $this->installSchema('node', array('node_access')); $this->installSchema('file', array('file_usage')); $this->installConfig(['node']); diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php index d39cd54..e511305 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php @@ -74,9 +74,6 @@ protected function setUp() { ->grantPermission('view test entity') ->save(); - // The label formatter rendering generates links, so build the router. - $this->installSchema('system', 'router'); - $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->entityType, 'default', array(), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); // Set up a field, so that the entity that'll be referenced bubbles up a diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php index ddcf3f9..b0cfd94 100644 --- a/core/modules/field/src/Tests/FieldUnitTestBase.php +++ b/core/modules/field/src/Tests/FieldUnitTestBase.php @@ -50,7 +50,7 @@ protected function setUp() { $this->installEntitySchema('entity_test'); $this->installEntitySchema('user'); - $this->installSchema('system', ['router', 'sequences', 'key_value']); + $this->installSchema('system', ['sequences', 'key_value']); // Set default storage backend and configure the theme system. $this->installConfig(array('field', 'system')); diff --git a/core/modules/field/src/Tests/String/RawStringFormatterTest.php b/core/modules/field/src/Tests/String/RawStringFormatterTest.php index a5d3722..59fde5f 100644 --- a/core/modules/field/src/Tests/String/RawStringFormatterTest.php +++ b/core/modules/field/src/Tests/String/RawStringFormatterTest.php @@ -58,7 +58,6 @@ protected function setUp() { // Configure the theme system. $this->installConfig(array('system', 'field')); - $this->installSchema('system', 'router'); $this->installEntitySchema('entity_test'); $this->entityType = 'entity_test'; diff --git a/core/modules/field/src/Tests/String/StringFormatterTest.php b/core/modules/field/src/Tests/String/StringFormatterTest.php index 28ec21c..c5a1dc2 100644 --- a/core/modules/field/src/Tests/String/StringFormatterTest.php +++ b/core/modules/field/src/Tests/String/StringFormatterTest.php @@ -58,7 +58,6 @@ protected function setUp() { // Configure the theme system. $this->installConfig(array('system', 'field')); - $this->installSchema('system', 'router'); $this->installEntitySchema('entity_test_rev'); $this->entityType = 'entity_test_rev'; diff --git a/core/modules/field/src/Tests/String/UuidFormatterTest.php b/core/modules/field/src/Tests/String/UuidFormatterTest.php index af34d3f..a4e971e 100644 --- a/core/modules/field/src/Tests/String/UuidFormatterTest.php +++ b/core/modules/field/src/Tests/String/UuidFormatterTest.php @@ -32,7 +32,6 @@ protected function setUp() { parent::setUp(); $this->installConfig(['system', 'field']); - $this->installSchema('system', 'router'); $this->installEntitySchema('entity_test'); } diff --git a/core/modules/filter/src/Tests/TextFormatElementFormTest.php b/core/modules/filter/src/Tests/TextFormatElementFormTest.php index 56450ff..0c13574 100644 --- a/core/modules/filter/src/Tests/TextFormatElementFormTest.php +++ b/core/modules/filter/src/Tests/TextFormatElementFormTest.php @@ -41,7 +41,7 @@ class TextFormatElementFormTest extends KernelTestBase implements FormInterface protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); - $this->installSchema('system', ['sequences', 'router']); + $this->installSchema('system', 'sequences'); $this->installConfig(['filter', 'filter_test']); /* @var \Drupal\Core\Render\ElementInfoManager $manager */ $manager = \Drupal::service('plugin.manager.element_info'); diff --git a/core/modules/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php index 104a5e2..4a64ba5 100644 --- a/core/modules/hal/src/Tests/NormalizerTestBase.php +++ b/core/modules/hal/src/Tests/NormalizerTestBase.php @@ -61,7 +61,7 @@ */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('url_alias', 'router')); + $this->installSchema('system', 'url_alias'); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); // If the concrete test sub-class installs the Node or Comment modules, @@ -83,7 +83,6 @@ protected function setUp() { $class = get_parent_class($class); } $this->installConfig(array('field', 'language')); - \Drupal::service('router.builder')->rebuild(); // Add German as a language. ConfigurableLanguage::create(array( diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentCacheabilityBubblingTest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentCacheabilityBubblingTest.php index b8e4750..7fcb960 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentCacheabilityBubblingTest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentCacheabilityBubblingTest.php @@ -39,7 +39,7 @@ protected function setUp() { $this->installEntitySchema('menu_link_content'); $this->installEntitySchema('user'); - $this->installSchema('system', ['url_alias', 'router']); + $this->installSchema('system', 'url_alias'); // Ensure that the weight of module_link_content is higher than system. // @see menu_link_content_install() diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php index 33a1667..6fec4ab 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentDeriverTest.php @@ -33,7 +33,6 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('menu_link_content'); - $this->installSchema('system', 'router'); } /** diff --git a/core/modules/menu_link_content/src/Tests/PathAliasMenuLinkContentTest.php b/core/modules/menu_link_content/src/Tests/PathAliasMenuLinkContentTest.php index f8ac2bc..50de241 100644 --- a/core/modules/menu_link_content/src/Tests/PathAliasMenuLinkContentTest.php +++ b/core/modules/menu_link_content/src/Tests/PathAliasMenuLinkContentTest.php @@ -32,7 +32,7 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('menu_link_content'); - $this->installSchema('system', ['url_alias', 'router']); + $this->installSchema('system', 'url_alias'); // Ensure that the weight of module_link_content is higher than system. // @see menu_link_content_install() diff --git a/core/modules/rest/src/Tests/RestLinkManagerTest.php b/core/modules/rest/src/Tests/RestLinkManagerTest.php index 5bb97f3..1d8cc0e 100644 --- a/core/modules/rest/src/Tests/RestLinkManagerTest.php +++ b/core/modules/rest/src/Tests/RestLinkManagerTest.php @@ -21,14 +21,6 @@ class RestLinkManagerTest extends KernelTestBase { public static $modules = ['rest', 'rest_test', 'system']; /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - $this->installSchema('system', ['router']); - } - - /** * Tests that type hooks work as expected. */ public function testRestLinkManagers() { diff --git a/core/modules/serialization/src/Tests/NormalizerTestBase.php b/core/modules/serialization/src/Tests/NormalizerTestBase.php index 3540a28..0bd5023 100644 --- a/core/modules/serialization/src/Tests/NormalizerTestBase.php +++ b/core/modules/serialization/src/Tests/NormalizerTestBase.php @@ -23,7 +23,7 @@ protected function setUp() { $this->installEntitySchema('entity_test_mulrev'); $this->installEntitySchema('user'); - $this->installSchema('system', array('url_alias', 'router')); + $this->installSchema('system', 'url_alias'); $this->installConfig(array('field')); \Drupal::moduleHandler()->invoke('rest', 'install'); diff --git a/core/modules/simpletest/src/RouteBuilder.php b/core/modules/simpletest/src/RouteBuilder.php new file mode 100644 index 0000000..dea8cde --- /dev/null +++ b/core/modules/simpletest/src/RouteBuilder.php @@ -0,0 +1,69 @@ +service)) { + $container = \Drupal::getContainer(); + $this->service = $container->get('simpletest.router.builder'); + $schema = $container->get('database')->schema(); + if (!$schema->tableExists('router')) { + $schema->createTable('router', drupal_get_module_schema('system', 'router')); + } + } + return $this->service; + } + + /** + * {@inheritdoc} + */ + public function setRebuildNeeded() { + return $this->lazyLoadItself()->setRebuildNeeded(); + } + + /** + * {@inheritdoc} + */ + public function rebuild() { + return $this->lazyLoadItself()->rebuild(); + } + + /** + * {@inheritdoc} + */ + public function rebuildIfNeeded() { + return $this->lazyLoadItself()->rebuildIfNeeded(); + } + + /** + * {@inheritdoc} + */ + public function destruct() { + return $this->lazyLoadItself()->destruct(); + } + +} diff --git a/core/modules/simpletest/src/TestServiceProvider.php b/core/modules/simpletest/src/TestServiceProvider.php index 9ba565a..9f16419 100644 --- a/core/modules/simpletest/src/TestServiceProvider.php +++ b/core/modules/simpletest/src/TestServiceProvider.php @@ -34,10 +34,12 @@ function register(ContainerBuilder $container) { public function alter(ContainerBuilder $container) { if (static::$currentTest instanceof KernelTestBase) { // While $container->get() does a recursive resolve, getDefinition() does - // not so do it ourselves. - for ($id = 'router.route_provider'; $container->hasAlias($id); $id = (string) $container->getAlias($id)); - $container->setDefinition('simpletest.router.route_provider', $container->getDefinition($id)); - $container->setDefinition('router.route_provider', new Definition('Drupal\simpletest\RouteProvider')); + // not, so do it ourselves. + foreach (['router.route_provider' => 'RouteProvider', 'router.builder' => 'RouteBuilder'] as $original_id => $class) { + for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id)); + $container->setDefinition("simpletest.$original_id", $container->getDefinition($id)); + $container->setDefinition($id, new Definition('Drupal\simpletest\\' . $class)); + } } } } diff --git a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php index 48623c0..dc967e9 100644 --- a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php +++ b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php @@ -51,7 +51,6 @@ class AttachedAssetsTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->assetResolver = $this->container->get('asset.resolver'); $this->renderer = $this->container->get('renderer'); } diff --git a/core/modules/system/src/Tests/Common/PageRenderTest.php b/core/modules/system/src/Tests/Common/PageRenderTest.php index a8b70c1..e03febf 100644 --- a/core/modules/system/src/Tests/Common/PageRenderTest.php +++ b/core/modules/system/src/Tests/Common/PageRenderTest.php @@ -21,7 +21,6 @@ class PageRenderTest extends KernelTestBase { */ function testHookPageAttachmentsExceptions() { $this->enableModules(['common_test', 'system']); - $this->installSchema('system', 'router'); $this->assertPageRenderHookExceptions('common_test', 'hook_page_attachments'); } @@ -30,7 +29,6 @@ function testHookPageAttachmentsExceptions() { */ function testHookPageAlter() { $this->enableModules(['common_test', 'system']); - $this->installSchema('system', 'router'); $this->assertPageRenderHookExceptions('common_test', 'hook_page_attachments_alter'); } diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php index 723500a..4b9db14 100644 --- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php @@ -28,7 +28,6 @@ class RenderElementTypesTest extends KernelTestBase { protected function setUp() { parent::setUp(); $this->installConfig(array('system')); - $this->installSchema('system', array('router')); } /** diff --git a/core/modules/system/src/Tests/Element/PathElementFormTest.php b/core/modules/system/src/Tests/Element/PathElementFormTest.php index ebfba8e..d9ad44e 100644 --- a/core/modules/system/src/Tests/Element/PathElementFormTest.php +++ b/core/modules/system/src/Tests/Element/PathElementFormTest.php @@ -42,7 +42,7 @@ class PathElementFormTest extends KernelTestBase implements FormInterface { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', ['router', 'sequences', 'key_value_expire']); + $this->installSchema('system', ['sequences', 'key_value_expire']); $this->installEntitySchema('user'); /** @var \Drupal\user\RoleInterface $role */ $role = Role::create(array( diff --git a/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php b/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php index c8b28e6..02ff6e8 100644 --- a/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php +++ b/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php @@ -50,7 +50,7 @@ class EntityAutocompleteElementFormTest extends EntityUnitTestBase implements Fo protected function setUp() { parent::setUp(); - $this->installSchema('system', ['router', 'key_value_expire']); + $this->installSchema('system', ['key_value_expire']); $this->testUser = User::create(array( 'name' => 'foobar1', diff --git a/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php index d2ed9af..9df409b 100644 --- a/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php @@ -29,7 +29,7 @@ class FieldWidgetConstraintValidatorTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', ['router', 'key_value']); + $this->installSchema('system', 'key_value'); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test_composite_constraint'); diff --git a/core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php b/core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php index b63ea0d..171a4f4 100644 --- a/core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php +++ b/core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php @@ -27,15 +27,6 @@ class StackKernelIntegrationTest extends KernelTestBase { public static $modules = array('httpkernel_test', 'system'); /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - $this->installSchema('system', 'router'); - } - - /** * Tests a request. */ public function testRequest() { diff --git a/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php b/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php index 011b58f..2117be8 100644 --- a/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php +++ b/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php @@ -53,7 +53,6 @@ class MenuLinkTreeTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->installEntitySchema('menu_link_content'); $this->linkTree = $this->container->get('menu.link_tree'); diff --git a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php index eeaff18..7b0f6cc 100644 --- a/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php +++ b/core/modules/system/src/Tests/Routing/ExceptionHandlingTest.php @@ -25,15 +25,6 @@ class ExceptionHandlingTest extends KernelTestBase { public static $modules = ['system', 'router_test']; /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - $this->installSchema('system', ['router']); - } - - /** * Tests the exception handling for json and 403 status code. */ public function testJson403() { diff --git a/core/modules/system/src/Tests/System/TrustedHostsTest.php b/core/modules/system/src/Tests/System/TrustedHostsTest.php index d9da707..73f8be0 100644 --- a/core/modules/system/src/Tests/System/TrustedHostsTest.php +++ b/core/modules/system/src/Tests/System/TrustedHostsTest.php @@ -65,6 +65,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( diff --git a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php index 2a19787..e1cc2dd 100644 --- a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php +++ b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php @@ -78,9 +78,6 @@ function testUserEditForm() { // Install default configuration; required for AccountFormController. $this->installConfig(array('user')); - // Install the router table. - $this->installSchema('system', ['router']); - $form = $this->buildAccountForm('default'); // Verify name and pass field order. diff --git a/core/modules/views/src/Tests/ViewKernelTestBase.php b/core/modules/views/src/Tests/ViewKernelTestBase.php index a45d89d..0d53cd0 100644 --- a/core/modules/views/src/Tests/ViewKernelTestBase.php +++ b/core/modules/views/src/Tests/ViewKernelTestBase.php @@ -42,7 +42,7 @@ protected function setUp($import_test_views = TRUE) { parent::setUp(); - $this->installSchema('system', array('router', 'sequences')); + $this->installSchema('system', 'sequences'); $this->setUpFixtures(); if ($import_test_views) {