You are here

public function UninstallTest::testFailedInstallStatus in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Module/UninstallTest.php \Drupal\system\Tests\Module\UninstallTest::testFailedInstallStatus()

Tests that a module which fails to install can still be uninstalled.

File

core/modules/system/src/Tests/Module/UninstallTest.php, line 129
Contains \Drupal\system\Tests\Module\UninstallTest.

Class

UninstallTest
Tests the uninstallation of modules.

Namespace

Drupal\system\Tests\Module

Code

public function testFailedInstallStatus() {
  $account = $this
    ->drupalCreateUser(array(
    'administer modules',
  ));
  $this
    ->drupalLogin($account);
  $message = 'Exception thrown when installing module_installer_config_test with an invalid configuration file.';
  try {
    $this->container
      ->get('module_installer')
      ->install(array(
      'module_installer_config_test',
    ));
    $this
      ->fail($message);
  } catch (EntityMalformedException $e) {
    $this
      ->pass($message);
  }

  // Even though the module failed to install properly, its configuration
  // status is "enabled" and should still be available to uninstall.
  $this
    ->drupalGet('admin/modules/uninstall');
  $this
    ->assertText('Module installer config test');
  $edit['uninstall[module_installer_config_test]'] = TRUE;
  $this
    ->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPostForm(NULL, NULL, t('Uninstall'));
  $this
    ->assertText(t('The selected modules have been uninstalled.'));
  $this
    ->assertNoText('Module installer config test');
}