You are here

public function ModuleHandlerTest::testSetModuleList 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::testSetModuleList()

Ensure setting the module list replaces the module list and resets internal structures.

@covers ::setModuleList

File

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

Class

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

Namespace

Drupal\Tests\Core\Extension

Code

public function testSetModuleList() {
  $module_handler = $this
    ->getMockBuilder('Drupal\\Core\\Extension\\ModuleHandler')
    ->setConstructorArgs(array(
    $this->root,
    array(),
    $this->cacheBackend,
  ))
    ->setMethods(array(
    'resetImplementations',
  ))
    ->getMock();

  // Ensure we reset implementations when settings a new modules list.
  $module_handler
    ->expects($this
    ->once())
    ->method('resetImplementations');

  // Make sure we're starting empty.
  $this
    ->assertEquals($module_handler
    ->getModuleList(), array());

  // Replace the list with a prebuilt list.
  $module_handler
    ->setModuleList($this->moduleHandler
    ->getModuleList());

  // Ensure those changes are stored.
  $this
    ->assertEquals($this->moduleHandler
    ->getModuleList(), $module_handler
    ->getModuleList());
}