c15e7fba7c0b5c961aa2028b33a125ea784f676d
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Extension / ModuleInstallerTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Extension;
4
5 use Drupal\Core\Database\Database;
6 use Drupal\KernelTests\KernelTestBase;
7 use Symfony\Component\Routing\Exception\RouteNotFoundException;
8
9 /**
10  * Tests the ModuleInstaller class.
11  *
12  * @coversDefaultClass \Drupal\Core\Extension\ModuleInstaller
13  *
14  * @group Extension
15  */
16 class ModuleInstallerTest extends KernelTestBase {
17
18   /**
19    * Modules to install.
20    *
21    * The System module is required because system_rebuild_module_data() is used.
22    *
23    * @var array
24    */
25   public static $modules = ['system'];
26
27   /**
28    * Tests that routes are rebuilt during install and uninstall of modules.
29    *
30    * @covers ::install
31    * @covers ::uninstall
32    */
33   public function testRouteRebuild() {
34     // Remove the routing table manually to ensure it can be created lazily
35     // properly.
36     Database::getConnection()->schema()->dropTable('router');
37
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());
41
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');
45   }
46
47 }