Skip to content
Snippets Groups Projects
Commit a3c32ebb authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2848553 by Sam152, Jaesin, dawehner: Make sure all 'configure' links are valid routes

parent 2fd6026a
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -4,6 +4,6 @@ description: 'Provides moderation states for content' ...@@ -4,6 +4,6 @@ description: 'Provides moderation states for content'
version: VERSION version: VERSION
core: 8.x core: 8.x
package: Core (Experimental) package: Core (Experimental)
configure: content_moderation.overview configure: entity.workflow.collection
dependencies: dependencies:
- workflows - workflows
...@@ -4,4 +4,4 @@ description: 'Provides UI and API for managing workflows. This module can be use ...@@ -4,4 +4,4 @@ description: 'Provides UI and API for managing workflows. This module can be use
version: VERSION version: VERSION
core: 8.x core: 8.x
package: Core (Experimental) package: Core (Experimental)
configure: workflows.overview configure: entity.workflow.collection
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
use Drupal\Core\Config\InstallStorage; use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\KernelTests\AssertConfigTrait; use Drupal\KernelTests\AssertConfigTrait;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
/** /**
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
class DefaultConfigTest extends KernelTestBase { class DefaultConfigTest extends KernelTestBase {
use AssertConfigTrait; use AssertConfigTrait;
use FileSystemModuleDiscoveryDataProviderTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -61,7 +63,7 @@ protected function setUp() { ...@@ -61,7 +63,7 @@ protected function setUp() {
/** /**
* Tests if installed config is equal to the exported config. * Tests if installed config is equal to the exported config.
* *
* @dataProvider providerTestModuleConfig * @dataProvider coreModuleListDataProvider
*/ */
public function testModuleConfig($module) { public function testModuleConfig($module) {
// System and user are required in order to be able to install some of the // System and user are required in order to be able to install some of the
...@@ -142,24 +144,4 @@ protected function doTestsOnConfigStorage(StorageInterface $default_config_stora ...@@ -142,24 +144,4 @@ protected function doTestsOnConfigStorage(StorageInterface $default_config_stora
} }
} }
/**
* Test data provider for ::testModuleConfig().
*
* @return array
* An array of module names to test.
*/
public function providerTestModuleConfig() {
$module_dirs = array_keys(iterator_to_array(new \FilesystemIterator(__DIR__ . '/../../../../modules/')));
$module_names = array_map(function($path) {
return str_replace(__DIR__ . '/../../../../modules/', '', $path);
}, $module_dirs);
$modules_keyed = array_combine($module_names, $module_names);
$data = array_map(function ($module) {
return [$module];
}, $modules_keyed);
return $data;
}
} }
<?php
namespace Drupal\KernelTests\Core\Extension;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the configure route for core modules.
*
* @group Module
*/
class ModuleConfigureRouteTest extends KernelTestBase {
use FileSystemModuleDiscoveryDataProviderTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'user'];
/**
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected $routeProvider;
/**
* An array of module info.
*
* @var array
*/
protected $moduleInfo;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->routeProvider = \Drupal::service('router.route_provider');
$this->moduleInfo = system_rebuild_module_data();
}
/**
* Test the module configure routes exist.
*
* @dataProvider coreModuleListDataProvider
*/
function testModuleConfigureRoutes($module) {
$module_info = $this->moduleInfo[$module]->info;
if (isset($module_info['configure'])) {
$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));
}
}
}
<?php
namespace Drupal\KernelTests;
/**
* A trait used in testing for providing a list of modules in a dataProvider.
*/
trait FileSystemModuleDiscoveryDataProviderTrait {
/**
* A data provider that lists every module in core.
*
* @return array
* An array of module names to test.
*/
public function coreModuleListDataProvider() {
$module_dirs = array_keys(iterator_to_array(new \FilesystemIterator(__DIR__ . '/../../../modules/')));
$module_names = array_map(function($path) {
return str_replace(__DIR__ . '/../../../modules/', '', $path);
}, $module_dirs);
$modules_keyed = array_combine($module_names, $module_names);
$data = array_map(function ($module) {
return [$module];
}, $modules_keyed);
return $data;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment