public function ModuleHandlerTest::testCachedGetImplementations in Drupal 8
Test getImplementations.
@covers ::getImplementations @covers ::getImplementationInfo
File
- core/
tests/ Drupal/ Tests/ Core/ Extension/ ModuleHandlerTest.php, line 342
Class
- ModuleHandlerTest
- @coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses
Namespace
Drupal\Tests\Core\ExtensionCode
public function testCachedGetImplementations() {
$this->cacheBackend
->expects($this
->exactly(1))
->method('get')
->will($this
->onConsecutiveCalls((object) [
'data' => [
'hook' => [
'module_handler_test' => 'test',
],
],
]));
// Ensure buildImplementationInfo doesn't get called and that we work off cached results.
$module_handler = $this
->getMockBuilder(ModuleHandler::class)
->setConstructorArgs([
$this->root,
[
'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
],
],
$this->cacheBackend,
])
->setMethods([
'buildImplementationInfo',
'loadInclude',
])
->getMock();
$module_handler
->load('module_handler_test');
$module_handler
->expects($this
->never())
->method('buildImplementationInfo');
$module_handler
->expects($this
->once())
->method('loadInclude');
$this
->assertEquals([
'module_handler_test',
], $module_handler
->getImplementations('hook'));
}