You are here

public function ModuleInstallerTest::testRouteRebuild in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testRouteRebuild()
  2. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testRouteRebuild()

Tests that routes are rebuilt during install and uninstall of modules.

@covers ::install @covers ::uninstall

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php, line 26

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testRouteRebuild() {

  // Remove the routing table manually to ensure it can be created lazily
  // properly.
  Database::getConnection()
    ->schema()
    ->dropTable('router');
  $this->container
    ->get('module_installer')
    ->install([
    'router_test',
  ]);
  $route = $this->container
    ->get('router.route_provider')
    ->getRouteByName('router_test.1');
  $this
    ->assertEquals('/router_test/test1', $route
    ->getPath());
  $this->container
    ->get('module_installer')
    ->uninstall([
    'router_test',
  ]);
  $this
    ->expectException(RouteNotFoundException::class);
  $this->container
    ->get('router.route_provider')
    ->getRouteByName('router_test.1');
}