You are here

public function InstallerTest::testInstalled in Drupal 10

Confirms that the installation succeeded.

File

core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php, line 126

Class

InstallerTest
Tests the interactive installer.

Namespace

Drupal\FunctionalTests\Installer

Code

public function testInstalled() {
  $this
    ->assertSession()
    ->addressEquals('user/1');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $database = Database::getConnection();
  $module = $database
    ->getProvider();
  $module_handler = \Drupal::service('module_handler');

  // Ensure the update module is not installed.
  $this
    ->assertFalse($module_handler
    ->moduleExists('update'), 'The Update module is not installed.');

  // Assert that the module that is providing the database driver has been
  // installed.
  $this
    ->assertTrue($module_handler
    ->moduleExists($module));

  // The module that is providing the database driver should be uninstallable.
  try {
    $this->container
      ->get('module_installer')
      ->uninstall([
      $module,
    ]);
    $this
      ->fail("Uninstalled {$module} module.");
  } catch (ModuleUninstallValidatorException $e) {
    $module_name = $module_handler
      ->getName($module);
    $driver = $database
      ->driver();
    $this
      ->assertStringContainsString("The module '{$module_name}' is providing the database driver '{$driver}'.", $e
      ->getMessage());
  }
}