function ModuleLegacyTest::testModuleLoadInclude

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php \Drupal\KernelTests\Core\Extension\ModuleLegacyTest::testModuleLoadInclude()
  2. 10 core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php \Drupal\KernelTests\Core\Extension\ModuleLegacyTest::testModuleLoadInclude()

Test deprecation of module_load_include() function.

File

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

Class

ModuleLegacyTest
Tests deprecations from <a href="/api/drupal/core%21includes%21module.inc/11.x" title="API for loading and interacting with Drupal modules." class="local">module.inc</a> file.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testModuleLoadInclude() {
    $this->assertFalse($this->container
        ->get('module_handler')
        ->moduleExists('module_test'), 'Ensure module is uninstalled so we test the ability to include uninstalled code.');
    $this->expectDeprecation('module_load_include() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. Instead, you should use \\Drupal::moduleHandler()->loadInclude(). Note that including code from uninstalled extensions is no longer supported. See https://www.drupal.org/node/2948698');
    $filename = module_load_include('inc', 'module_test', 'module_test.file');
    $this->assertStringEndsWith("module_test.file.inc", $filename);
}

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