You are here

public function ModuleHandlerTest::testAddModule in Drupal 8

Test adding a module.

@covers ::addModule @covers ::add

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 205

Class

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

Namespace

Drupal\Tests\Core\Extension

Code

public function testAddModule() {
  $module_handler = $this
    ->getMockBuilder(ModuleHandler::class)
    ->setConstructorArgs([
    $this->root,
    [],
    $this->cacheBackend,
  ])
    ->setMethods([
    'resetImplementations',
  ])
    ->getMock();

  // Ensure we reset implementations when settings a new modules list.
  $module_handler
    ->expects($this
    ->once())
    ->method('resetImplementations');
  $module_handler
    ->addModule('module_handler_test', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test');
  $this
    ->assertTrue($module_handler
    ->moduleExists('module_handler_test'));
}