ModuleConfigureRouteTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Extension;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
use Drupal\KernelTests\KernelTestBase;
class ModuleConfigureRouteTest extends KernelTestBase {
use FileSystemModuleDiscoveryDataProviderTrait;
public static $modules = [
'system',
'user',
];
protected $routeProvider;
protected $moduleInfo;
protected function setUp() {
parent::setUp();
$this->routeProvider = \Drupal::service('router.route_provider');
$this->moduleInfo = \Drupal::service('extension.list.module')
->getList();
}
public function testModuleConfigureRoutes($module) {
$module_info = $this->moduleInfo[$module]->info;
if (!isset($module_info['configure'])) {
$this
->markTestSkipped("{$module} has no configure route");
}
$this->container
->get('module_installer')
->install([
$module,
]);
$route = $this->routeProvider
->getRouteByName($module_info['configure']);
$this
->assertNotEmpty($route, sprintf('The configure route for the "%s" module was found.', $module));
}
}