You are here

public function ModuleHandlerTest::testModuleReloading in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testModuleReloading()

Test reload method.

@covers ::reload

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 91
Contains \Drupal\Tests\Core\Extension\ModuleHandlerTest.

Class

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

Namespace

Drupal\Tests\Core\Extension

Code

public function testModuleReloading() {
  $module_handler = $this
    ->getMockBuilder('Drupal\\Core\\Extension\\ModuleHandler')
    ->setConstructorArgs(array(
    $this->root,
    array(
      'module_handler_test' => array(
        '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(array(
    'load',
  ))
    ->getMock();

  // First reload.
  $module_handler
    ->expects($this
    ->at(0))
    ->method('load')
    ->with($this
    ->equalTo('module_handler_test'));

  // Second reload.
  $module_handler
    ->expects($this
    ->at(1))
    ->method('load')
    ->with($this
    ->equalTo('module_handler_test'));
  $module_handler
    ->expects($this
    ->at(2))
    ->method('load')
    ->with($this
    ->equalTo('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();
}