You are here

public function ModuleHandlerTest::testGetHookInfo in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testGetHookInfo()

Test hook_hook_info() fetching through getHookInfo().

@covers ::getHookInfo @covers ::buildHookInfo

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 421
Contains \Drupal\Tests\Core\Extension\ModuleHandlerTest.

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler @group Extension

Namespace

Drupal\Tests\Core\Extension

Code

public function testGetHookInfo() {

  // Set up some synthetic results.
  $this->cacheBackend
    ->expects($this
    ->exactly(2))
    ->method('get')
    ->will($this
    ->onConsecutiveCalls(NULL, (object) array(
    'data' => array(
      'hook_foo' => array(
        'group' => 'hook',
      ),
    ),
  )));

  // Results from building from mocked environment.
  $this
    ->assertEquals(array(
    'hook' => array(
      'group' => 'hook',
    ),
  ), $this->moduleHandler
    ->getHookInfo());

  // Reset local cache so we get our synthetic result from the cache handler.
  $this->moduleHandler
    ->resetImplementations();
  $this
    ->assertEquals(array(
    'hook_foo' => array(
      'group' => 'hook',
    ),
  ), $this->moduleHandler
    ->getHookInfo());
}