You are here

public function AdvancedHelpHintTest::testHookHelp in Freelinking 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/AdvancedHelpHintTest.php \Drupal\Tests\freelinking\Kernel\AdvancedHelpHintTest::testHookHelp()

Asserts hook_help() is functional.

@dataProvider hookHelpProvider

Parameters

array $modules: An array of optional module dependencies.

Throws

\Exception

File

tests/src/Kernel/AdvancedHelpHintTest.php, line 37

Class

AdvancedHelpHintTest
Tests hook_help implementation.

Namespace

Drupal\Tests\freelinking\Kernel

Code

public function testHookHelp(array $modules = []) {
  $routeMatchProphet = $this
    ->prophesize('\\Drupal\\Core\\Routing\\RouteMatchInterface');
  $routeMatch = $routeMatchProphet
    ->reveal();
  if (!empty($modules)) {
    $module_handler = $this->container
      ->get('module_handler');
    $discovery = new ExtensionDiscovery($this->root);
    $discovery
      ->setProfileDirectories([]);
    $list = $discovery
      ->scan('module');
    foreach ($modules as $name) {
      if (!isset($list[$name])) {
        throw new \Exception("Unavailable module: '{$name}'. If this module needs to be downloaded separately, annotate the test class with '@requires module {$name}'.");
      }
      $extension = $list[$name];
      $module_handler
        ->addModule($name, $extension
        ->getPath());
      $module_handler
        ->load($name);
    }
  }
  $help = freelinking_help('help.page.freelinking', $routeMatch);
  $this
    ->assertNotEmpty($help);
}