You are here

function acquia_spi_test_status in Acquia Connector 7.3

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \acquia_spi_test_status()
  2. 7.2 acquia_spi/acquia_spi.module \acquia_spi_test_status()

Determines the status of all user-contributed tests.

Logs any failures to a tracking table.

Parameters

bool $log: (Optional) If TRUE, log all failures.

Return value

array An associative array containing any tests which failed validation.

1 call to acquia_spi_test_status()
acquia_spi_requirements in acquia_spi/acquia_spi.install
Implements hook_requirements().
1 string reference to 'acquia_spi_test_status'
acquia_spi_menu in acquia_spi/acquia_spi.module
Implements hook_menu().

File

acquia_spi/acquia_spi.module, line 899
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_test_status($log = FALSE) {
  $custom_data = array();

  // Iterate through modules which contain hook_acquia_spi_test().
  foreach (module_implements('acquia_spi_test') as $module) {
    $function = $module . '_acquia_spi_test';
    if (function_exists($function)) {
      $result = acquia_spi_test_validate($function());
      if (!$result['result']) {
        $custom_data[$module] = $result;
        foreach ($result['failure'] as $test_name => $test_failures) {
          foreach ($test_failures as $test_param => $test_value) {
            $variables = array(
              '!module' => $module,
              '@message' => $test_value['message'],
              '!param_name' => $test_param,
              '!test' => $test_name,
              '!value' => $test_value['value'],
            );

            // Only log if we're performing a full validation check.
            if ($log) {
              drupal_set_message(t("Custom test validation failed for !test in !module and has been logged: @message for parameter '!param_name'; current value '!value'.", $variables), 'error');
              watchdog('acquia spi test', "<em>Custom test validation failed</em>: @message for parameter '!param_name'; current value '!value'. (<em>Test '!test_name' in module '!module_name'</em>)", $variables, WATCHDOG_WARNING);
            }
          }
        }
      }
    }
  }

  // If a full validation check is being performed, go to the status page to
  // show the results.
  if ($log) {
    drupal_goto('admin/reports/status');
  }
  return $custom_data;
}