/** * Creates the results' table. * * @return array * The render array for the result table. */ public function results() { // If there are no results return. if (SecurityReview::getLastRun() <= 0) { return array(); } $checks = array(); foreach (Checklist::getChecks() as $check) { // Initialize with defaults. $checkInfo = array('result' => CheckResult::SKIPPED, 'message' => 'The check hasn\'t been run yet.', 'skipped' => $check->isSkipped()); // Get last result. $lastResult = $check->lastResult(); if ($lastResult != NULL) { $checkInfo['result'] = $lastResult->result(); $checkInfo['message'] = $lastResult->resultMessage(); } // Determine help link. $checkInfo['help_link'] = Drupal::l('Details', Url::fromRoute('security_review.help', array('namespace' => $check->getMachineNamespace(), 'title' => $check->getMachineTitle()))); // Add toggle button. $toggle_text = $check->isSkipped() ? 'Enable' : 'Skip'; $checkInfo['toggle_link'] = Drupal::l($toggle_text, Url::fromRoute('security_review.toggle', array('check_id' => $check->id()), array('query' => array('token' => Drupal::csrfToken()->get($check->id()))))); // Add to array of completed checks. $checks[] = $checkInfo; } return array('#theme' => 'run_and_review', '#date' => SecurityReview::getLastRun(), '#checks' => $checks, '#attached' => array('library' => array('security_review/run_and_review'))); }
/** * Tests the 'last_run' setting. */ public function testConfigLastRun() { $this->assertEqual(0, SecurityReview::getLastRun(), 'last_run is 0 by default.'); $time = time(); SecurityReview::setLastRun($time); $this->assertEqual($time, SecurityReview::getLastRun(), 'last_run set to now.'); }