function ModuleInstallerTest::testRouteRebuild

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testRouteRebuild()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testRouteRebuild()
  3. 10 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 30

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testRouteRebuild() : void {
    // 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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.