ModuleConfigureRouteTest.php

Same filename in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php
  2. 10 core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php
  3. 11.x core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php

Namespace

Drupal\KernelTests\Core\Extension

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;

/**
 * Tests the configure route for core modules.
 *
 * @group #slow
 * @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 = \Drupal::service('extension.list.module')->getList();
    }
    
    /**
     * Test the module configure routes exist.
     *
     * @dataProvider coreModuleListDataProvider
     */
    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));
    }

}

Classes

Title Deprecated Summary
ModuleConfigureRouteTest Tests the configure route for core modules.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.