function ModuleHandlerTest::assertModuleList

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::assertModuleList()
  2. 10 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::assertModuleList()
  3. 11.x core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::assertModuleList()

Assert that the extension handler returns the expected values.

@internal

Parameters

array $expected_values: The expected values, sorted by weight and module name.

string $condition: The condition being tested, such as 'After adding a module'.

1 call to ModuleHandlerTest::assertModuleList()
ModuleHandlerTest::testModuleList in core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
The basic functionality of retrieving enabled modules.

File

core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php, line 70

Class

ModuleHandlerTest
Tests ModuleHandler functionality.

Namespace

Drupal\Tests\system\Kernel\Extension

Code

protected function assertModuleList(array $expected_values, string $condition) : void {
    $expected_values = array_values(array_unique($expected_values));
    $enabled_modules = array_keys($this->container
        ->get('module_handler')
        ->getModuleList());
    $this->assertEquals($expected_values, $enabled_modules, new FormattableMarkup('@condition: extension handler returns correct results', [
        '@condition' => $condition,
    ]));
}

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