HookRequirementsTest.php 936 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php

/**
 * @file
 * Definition of Drupal\system\Tests\Module\HookRequirementsTest.
 */

namespace Drupal\system\Tests\Module;

/**
11 12 13
 * Attempts enabling a module that fails hook_requirements('install').
 *
 * @group Module
14 15 16 17 18 19 20 21 22 23 24
 */
class HookRequirementsTest extends ModuleTestBase {
  /**
   * Assert that a module cannot be installed if it fails hook_requirements().
   */
  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';
25
    $this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
26 27

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