function ModuleHandlerTest::testLoadInclude

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testLoadInclude()
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testLoadInclude()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testLoadInclude()

@covers ::loadInclude

Note we load code, so isolate the test.

@runInSeparateProcess @preserveGlobalState disabled

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 285

Class

ModuleHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Extension%21ModuleHandler.php/class/ModuleHandler/9" title="Class that manages modules in a Drupal installation." class="local">\Drupal\Core\Extension\ModuleHandler</a> @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testLoadInclude() {
    $module_handler = $this->getModuleHandler();
    // Include exists.
    $this->assertEquals(__DIR__ . '/modules/module_handler_test/hook_include.inc', $module_handler->loadInclude('module_handler_test', 'inc', 'hook_include'));
    $this->assertTrue(function_exists('module_handler_test_hook_include'));
    // Include doesn't exist.
    $this->assertFalse($module_handler->loadInclude('module_handler_test', 'install'));
}

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