You are here

function simpletest_requirements in SimpleTest 7

Same name and namespace in other branches
  1. 8.3 simpletest.install \simpletest_requirements()
  2. 6.2 simpletest.install \simpletest_requirements()
  3. 6 simpletest.install \simpletest_requirements()
  4. 7.2 simpletest.install \simpletest_requirements()

Check that the cURL extension exists for PHP.

File

./simpletest.install, line 123
Install, update and uninstall functions for the simpletest module.

Code

function simpletest_requirements($phase) {
  $requirements = array();
  $t = get_t();
  $has_curl = function_exists('curl_init');
  $has_hash = function_exists('hash_hmac');
  $has_domdocument = class_exists('DOMDocument');
  $requirements['curl'] = array(
    'title' => $t('cURL'),
    'value' => $has_curl ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_curl) {
    $requirements['curl']['severity'] = REQUIREMENT_ERROR;
    $requirements['curl']['description'] = $t('Simpletest could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array(
      '@curl_url' => 'http://php.net/manual/en/curl.setup.php',
    ));
  }
  $requirements['hash'] = array(
    'title' => $t('hash'),
    'value' => $has_hash ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_hash) {
    $requirements['hash']['severity'] = REQUIREMENT_ERROR;
    $requirements['hash']['description'] = $t('Simpletest could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array(
      '@hash_url' => 'http://php.net/manual/en/book.hash.php',
    ));
  }
  $requirements['php_domdocument'] = array(
    'title' => $t('PHP DOMDocument class'),
    'value' => $has_domdocument ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_domdocument) {
    $requirements['php_domdocument']['severity'] = REQUIREMENT_ERROR;
    $requirements['php_domdocument']['description'] = t('SimpleTest requires the DOMDocument class to be available. Please check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', array(
      '@link-phpinfo' => url('admin/reports/status/php'),
    ));
  }
  return $requirements;
}