Exemplo n.º 1
0
 /**
  * Returns a check-specific help page.
  *
  * @param $namespace
  *   The namespace of the check.
  * @param $title
  *   The name of the check.
  *
  * @return array
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 private function checkHelp($namespace, $title)
 {
     // Get the requested check.
     $check = Checklist::getCheck($namespace, $title);
     // If the check doesn't exist, throw 404.
     if ($check == NULL) {
         throw new NotFoundHttpException();
     }
     // Print the help page.
     $output = array();
     $output[] = array('#type' => 'markup', '#markup' => '<h3>' . t($check->getTitle()) . '</h3>');
     $output[] = $check->help();
     // If the check is skipped print the skip message, else print the
     // evaluation.
     if ($check->isSkipped()) {
         if ($check->skippedBy() != NULL) {
             $user = Drupal::l($check->skippedBy()->getUsername(), $check->skippedBy()->urlInfo());
         } else {
             $user = '******';
         }
         $skipMessage = t('Check marked for skipping on !date by !user', array('!date' => format_date($check->skippedOn()), '!user' => $user));
         $output[] = array('#type' => 'markup', '#markup' => "<p>{$skipMessage}</p>");
     } else {
         // Evaluate last result, if any.
         $lastResult = $check->lastResult();
         if ($lastResult instanceof CheckResult) {
             // Separator.
             $output[] = array('#type' => 'markup', '#markup' => '<div />');
             // Evaluation page.
             $output[] = $check->evaluate($lastResult);
         }
     }
     // Return the completed page.
     return $output;
 }
Exemplo n.º 2
0
 /**
  * Tests the search functions of Checklist:
  *   getCheck().
  *   getCheckByIdentifier().
  */
 public function testCheckSearch()
 {
     foreach (Checklist::getChecks() as $check) {
         // getCheck().
         $found = Checklist::getCheck($check->getMachineNamespace(), $check->getMachineTitle());
         $this->assertNotNull($found, 'Found a check.');
         $this->assertEqual($check->id(), $found->id(), 'Found ' . $check->getTitle() . '.');
         // getCheckByIdentifier().
         $found = Checklist::getCheckByIdentifier($check->id());
         $this->assertNotNull($found, 'Found a check.');
         $this->assertEqual($check->id(), $found->id(), 'Found ' . $check->getTitle() . '.');
     }
 }