function InstallerTest::testInstalled

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php \Drupal\FunctionalTests\Installer\InstallerTest::testInstalled()
  2. 11.x core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php \Drupal\FunctionalTests\Installer\InstallerTest::testInstalled()

Confirms that the installation succeeded.

File

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

Class

InstallerTest
Tests the interactive installer.

Namespace

Drupal\FunctionalTests\Installer

Code

public function testInstalled() : void {
    $this->assertSession()
        ->addressEquals('user/1');
    $this->assertSession()
        ->statusCodeEquals(200);
    $database = Database::getConnection();
    $module = $database->getProvider();
    $module_handler = \Drupal::service('module_handler');
    $module_extension_list = \Drupal::service('extension.list.module');
    // 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_extension_list->getName($module);
        $driver = $database->driver();
        $this->assertStringContainsString("The module '{$module_name}' is providing the database driver '{$driver}'.", $e->getMessage());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.