function ModuleLegacyTest::testDrupalRequiredModules

Test deprecation of drupal_required_modules() function.

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php, line 39

Class

ModuleLegacyTest
Tests deprecations from module.inc file.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testDrupalRequiredModules() {
    $this->expectDeprecation("drupal_required_modules() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There's no replacement. See https://www.drupal.org/node/3262811");
    
    /** @var \Drupal\Core\Extension\InfoParserInterface $parser */
    $parser = \Drupal::service('info_parser');
    $listing = new ExtensionDiscovery(\Drupal::root());
    $files = $listing->scan('module');
    // Empty as there's no install profile.
    $required = [];
    foreach ($files as $name => $file) {
        $info = $parser->parse($file->getPathname());
        if (!empty($info) && !empty($info['required']) && $info['required']) {
            $required[] = $name;
        }
    }
    $this->assertSame($required, drupal_required_modules());
}

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