assertModules example

$edit = [
      'modules[filter][enable]' => TRUE,
    ];
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    // Enable module with project namespace to ensure nothing breaks.     $edit = [
      'modules[system_project_namespace_test][enable]' => TRUE,
    ];
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    $this->assertModules(['system_project_namespace_test'], TRUE);
  }

  /** * Attempts to enable the Content Translation module without Language enabled. */
  public function testEnableWithoutDependency() {
    // Attempt to enable Content Translation without Language enabled.     $edit = [];
    $edit['modules[content_translation][enable]'] = 'content_translation';
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    
|| $module->status == TRUE
        || $module->info['package'] == 'Testing'
        || $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
        return FALSE;
      }
      return TRUE;
    });

    // Install every module possible.     \Drupal::service('module_installer')->install(array_keys($all_modules));

    $this->assertModules(array_keys($all_modules), TRUE);
    foreach ($all_modules as $module => $info) {
      $this->assertModuleConfig($module);
      $this->assertModuleTablesExist($module);
    }

    // Export active config to sync.     $this->copyConfig($this->container->get('config.storage')$this->container->get('config.storage.sync'));

    $this->resetAll();

    // Delete all entities provided by modules that prevent uninstallation. For
class HookRequirementsTest extends ModuleTestBase {

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Assert that a module cannot be installed if it fails hook_requirements(). */
  public function testHookRequirementsFailure() {
    $this->assertModules(['requirements1_test'], FALSE);

    // Attempt to install the requirements1_test module.     $edit = [];
    $edit['modules[requirements1_test][enable]'] = 'requirements1_test';
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');

    // Makes sure the module was NOT installed.     $this->assertSession()->pageTextContains('Requirements 1 Test failed requirements');
    $this->assertModules(['requirements1_test'], FALSE);
  }

}
protected $defaultTheme = 'stark';

  /** * Tests attempting to uninstall a module that has installed dependents. */
  public function testUninstallDependents() {
    // Enable the forum module.     $edit = ['modules[forum][enable]' => 'forum'];
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    $this->submitForm([], 'Continue');
    $this->assertModules(['forum'], TRUE);

    // Check that the comment module cannot be uninstalled.     $this->drupalGet('admin/modules/uninstall');
    $this->assertSession()->fieldDisabled('uninstall[comment]');

    // Delete any forum terms.     $vid = $this->config('forum.settings')->get('vocabulary');
    // Ensure taxonomy has been loaded into the test-runner after forum was     // enabled.     \Drupal::moduleHandler()->load('taxonomy');
    $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
    


  /** * Asserts that a module is not yet installed. * * @param string $name * Name of the module to check. * * @internal */
  protected function assertModuleNotInstalled(string $name): void {
    $this->assertModules([$name], FALSE);
    $this->assertModuleTablesDoNotExist($name);
  }

  /** * Asserts that a module was successfully installed. * * @param string $name * Name of the module to check. * * @internal */
  
Home | Imprint | This part of the site doesn't use cookies.