3 namespace Drupal\KernelTests\Core\Extension;
5 use Drupal\Core\Database\Database;
6 use Drupal\KernelTests\KernelTestBase;
7 use Symfony\Component\Routing\Exception\RouteNotFoundException;
10 * Tests the ModuleInstaller class.
12 * @coversDefaultClass \Drupal\Core\Extension\ModuleInstaller
16 class ModuleInstallerTest extends KernelTestBase {
21 * The System module is required because system_rebuild_module_data() is used.
25 public static $modules = ['system'];
28 * Tests that routes are rebuilt during install and uninstall of modules.
33 public function testRouteRebuild() {
34 // Remove the routing table manually to ensure it can be created lazily
36 Database::getConnection()->schema()->dropTable('router');
38 $this->container->get('module_installer')->install(['router_test']);
39 $route = $this->container->get('router.route_provider')->getRouteByName('router_test.1');
40 $this->assertEquals('/router_test/test1', $route->getPath());
42 $this->container->get('module_installer')->uninstall(['router_test']);
43 $this->setExpectedException(RouteNotFoundException::class);
44 $this->container->get('router.route_provider')->getRouteByName('router_test.1');