function RouterTest::testRouterUninstallInstall
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterUninstallInstall()
- 10 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterUninstallInstall()
- 11.x core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterUninstallInstall()
Tests that routes no longer exist for a module that has been uninstalled.
File
-
core/
modules/ system/ tests/ src/ Functional/ Routing/ RouterTest.php, line 302
Class
- RouterTest
- Functional class for the full integrated routing system.
Namespace
Drupal\Tests\system\Functional\RoutingCode
public function testRouterUninstallInstall() {
\Drupal::service('module_installer')->uninstall([
'router_test',
]);
\Drupal::service('router.builder')->rebuild();
try {
\Drupal::service('router.route_provider')->getRouteByName('router_test.1');
$this->fail('Route was delete on uninstall.');
} catch (RouteNotFoundException $e) {
// Expected exception; just continue testing.
}
// Install the module again.
\Drupal::service('module_installer')->install([
'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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.