Commit a3c32ebb authored by alexpott's avatar alexpott

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

parent 2fd6026a
......@@ -4,6 +4,6 @@ description: 'Provides moderation states for content'
version: VERSION
core: 8.x
package: Core (Experimental)
configure: content_moderation.overview
configure: entity.workflow.collection
dependencies:
- workflows
......@@ -4,4 +4,4 @@ description: 'Provides UI and API for managing workflows. This module can be use
version: VERSION
core: 8.x
package: Core (Experimental)
configure: workflows.overview
configure: entity.workflow.collection
......@@ -6,6 +6,7 @@
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\KernelTests\AssertConfigTrait;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
use Drupal\KernelTests\KernelTestBase;
/**
......@@ -16,6 +17,7 @@
class DefaultConfigTest extends KernelTestBase {
use AssertConfigTrait;
use FileSystemModuleDiscoveryDataProviderTrait;
/**
* {@inheritdoc}
......@@ -61,7 +63,7 @@ protected function setUp() {
/**
* Tests if installed config is equal to the exported config.
*
* @dataProvider providerTestModuleConfig
* @dataProvider coreModuleListDataProvider
*/
public function testModuleConfig($module) {
// 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
}
}
/**
* 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment