ModuleConfigureRouteTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Drupal\KernelTests\Core\Extension;
  3. use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
  4. use Drupal\KernelTests\KernelTestBase;
  5. /**
  6. * Tests the configure route for core modules.
  7. *
  8. * @group #slow
  9. * @group Module
  10. */
  11. class ModuleConfigureRouteTest extends KernelTestBase {
  12. use FileSystemModuleDiscoveryDataProviderTrait;
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public static $modules = ['system', 'user'];
  17. /**
  18. * @var \Drupal\Core\Routing\RouteProviderInterface
  19. */
  20. protected $routeProvider;
  21. /**
  22. * An array of module info.
  23. *
  24. * @var array
  25. */
  26. protected $moduleInfo;
  27. /**
  28. * {@inheritdoc}
  29. */
  30. protected function setUp() {
  31. parent::setUp();
  32. $this->routeProvider = \Drupal::service('router.route_provider');
  33. $this->moduleInfo = \Drupal::service('extension.list.module')->getList();
  34. }
  35. /**
  36. * Test the module configure routes exist.
  37. *
  38. * @dataProvider coreModuleListDataProvider
  39. */
  40. public function testModuleConfigureRoutes($module) {
  41. $module_info = $this->moduleInfo[$module]->info;
  42. if (!isset($module_info['configure'])) {
  43. $this->markTestSkipped("$module has no configure route");
  44. }
  45. $this->container->get('module_installer')->install([$module]);
  46. $route = $this->routeProvider->getRouteByName($module_info['configure']);
  47. $this->assertNotEmpty($route, sprintf('The configure route for the "%s" module was found.', $module));
  48. }
  49. }