AdvancedHelpHintTest.php in Freelinking 4.0.x
File
tests/src/Kernel/AdvancedHelpHintTest.php
View source
<?php
namespace Drupal\Tests\freelinking\Kernel;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\KernelTests\KernelTestBase;
use Prophecy\PhpUnit\ProphecyTrait;
class AdvancedHelpHintTest extends KernelTestBase {
use ProphecyTrait;
protected static $modules = [
'filter',
'freelinking',
];
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);
}
public function hookHelpProvider() {
return [
[
[],
],
[
[
'advanced_help',
'advanced_help_hint',
],
],
];
}
}