function ModuleHandlerTest::testHasImplementations
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testHasImplementations()
- 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testHasImplementations()
Tests hasImplementations.
@covers ::hasImplementations
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ ModuleHandlerTest.php, line 354
Class
- ModuleHandlerTest
- @coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses
Namespace
Drupal\Tests\Core\ExtensionCode
public function testHasImplementations() {
$module_handler = $this->getMockBuilder(ModuleHandler::class)
->setConstructorArgs([
$this->root,
[],
$this->cacheBackend,
])
->onlyMethods([
'buildImplementationInfo',
])
->getMock();
$module_handler->expects($this->exactly(2))
->method('buildImplementationInfo')
->with('hook')
->willReturnOnConsecutiveCalls([], [
'mymodule' => FALSE,
]);
// ModuleHandler::buildImplementationInfo mock returns no implementations.
$this->assertFalse($module_handler->hasImplementations('hook'));
// Reset static caches.
$module_handler->resetImplementations();
// ModuleHandler::buildImplementationInfo mock returns an implementation.
$this->assertTrue($module_handler->hasImplementations('hook'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.