function HookRequirementsTest::testHookRequirementsFailure

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php \Drupal\Tests\system\Functional\Module\HookRequirementsTest::testHookRequirementsFailure()
  2. 10 core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php \Drupal\Tests\system\Functional\Module\HookRequirementsTest::testHookRequirementsFailure()
  3. 11.x core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php \Drupal\Tests\system\Functional\Module\HookRequirementsTest::testHookRequirementsFailure()

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

File

core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php, line 20

Class

HookRequirementsTest
Attempts enabling a module that fails hook_requirements('install').

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testHookRequirementsFailure() {
    $this->assertModules([
        'requirements1_test',
    ], FALSE);
    // Attempt to install the requirements1_test module.
    $edit = [];
    $edit['modules[requirements1_test][enable]'] = 'requirements1_test';
    $this->drupalPostForm('admin/modules', $edit, t('Install'));
    // Makes sure the module was NOT installed.
    $this->assertText(t('Requirements 1 Test failed requirements'), 'Modules status has been updated.');
    $this->assertModules([
        'requirements1_test',
    ], FALSE);
}

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