moduleInstaller example


  public function testModuleList() {
    $module_list = ['system'];
    $database_module = \Drupal::database()->getProvider();
    if ($database_module !== 'core') {
      $module_list[] = $database_module;
    }
    sort($module_list);
    $this->assertModuleList($module_list, 'Initial');

    // Try to install a new module.     $this->moduleInstaller()->install(['ban']);
    $module_list[] = 'ban';
    sort($module_list);
    $this->assertModuleList($module_list, 'After adding a module');

    // Try to mess with the module weights.     module_set_weight('ban', 20);

    // Move ban to the end of the array.     unset($module_list[array_search('ban', $module_list)]);
    $module_list[] = 'ban';
    $this->assertModuleList($module_list, 'After changing weights');

    

  public function testThemeInfoAlter() {
    $name = 'stark';
    $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE);

    $this->themeInstaller()->install([$name]);

    $themes = $this->themeHandler()->listInfo();
    $this->assertFalse(isset($themes[$name]->info['regions']['test_region']));

    // Install module_test.     $this->moduleInstaller()->install(['module_test'], FALSE);
    $this->assertTrue($this->moduleHandler()->moduleExists('module_test'));

    $themes = $this->themeHandler()->listInfo();
    $this->assertTrue(isset($themes[$name]->info['regions']['test_region']));

    // Legacy assertions.     // @todo Remove once theme initialization/info has been modernized.     // @see https://www.drupal.org/node/2228093     $info = \Drupal::service('extension.list.theme')->getExtensionInfo($name);
    $this->assertTrue(isset($info['regions']['test_region']));
    $regions = system_region_list($name);
    
Home | Imprint | This part of the site doesn't use cookies.