public function RouterTest::testRouterUninstallInstall in Drupal 9
Same name and namespace in other branches
- 8 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 311
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',
]);
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',
]);
$route = \Drupal::service('router.route_provider')
->getRouteByName('router_test.1');
$this
->assertNotNull($route, 'Route exists after module installation');
}