function ModuleHandlerTest::testGetHookInfo

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

Tests hook_hook_info() fetching through getHookInfo().

@covers ::getHookInfo @covers ::buildHookInfo

File

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

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 testGetHookInfo() {
    $module_handler = $this->getModuleHandler();
    // Set up some synthetic results.
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('get')
        ->will($this->onConsecutiveCalls(NULL, (object) [
        'data' => [
            'hook_foo' => [
                'group' => 'hook',
            ],
        ],
    ]));
    // Results from building from mocked environment.
    $this->assertEquals([
        'hook' => [
            'group' => 'hook',
        ],
    ], $module_handler->getHookInfo());
    // Reset local cache so we get our synthetic result from the cache handler.
    $module_handler->resetImplementations();
    $this->assertEquals([
        'hook_foo' => [
            'group' => 'hook',
        ],
    ], $module_handler->getHookInfo());
}

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