function HookRequirementsTest::testHookRequirementsFailure

Assert that a module cannot be installed if it fails hook_requirements().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Module/HookRequirementsTest.php, line 25
Definition of Drupal\system\Tests\Module\HookRequirementsTest.

Class

HookRequirementsTest
Tests failure of hook_requirements('install').

Namespace

Drupal\system\Tests\Module

Code

function testHookRequirementsFailure() {
  $this
    ->assertModules(array(
    'requirements1_test',
  ), FALSE);

  // Attempt to install the requirements1_test module.
  $edit = array();
  $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test';
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));

  // Makes sure the module was NOT installed.
  $this
    ->assertText(t('Requirements 1 Test failed requirements'), 'Modules status has been updated.');
  $this
    ->assertModules(array(
    'requirements1_test',
  ), FALSE);
}