function ModuleHandlerTest::testModuleReloading

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testModuleReloading()
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testModuleReloading()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testModuleReloading()

Tests reload method.

@covers ::reload

File

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

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler[[api-linebreak]] @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testModuleReloading() {
  $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,
  ])
    ->onlyMethods([
    'load',
  ])
    ->getMock();
  $module_handler->expects($this->exactly(3))
    ->method('load')
    ->withConsecutive([
    'module_handler_test',
  ], [
    'module_handler_test',
  ], [
    'module_handler_test_added',
  ]);
  $module_handler->reload();
  $module_handler->addModule('module_handler_test_added', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_added');
  $module_handler->reload();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.