/**
  *
  * @param tx_caretaker_TestNode $node
  * @param tx_caretaker_NodeResult $latestTestResult
  * @param array $options
  * @return boolean
  */
 protected function shouldReturnLatestResult($node, $latestTestResult, $options)
 {
     $forceUpdate = isset($options['forceUpdate']) && $options['forceUpdate'] === TRUE;
     $returnLatestResult = FALSE;
     if (!$forceUpdate) {
         if ($latestTestResult) {
             // test is not in due state so retry
             switch ($latestTestResult->getState()) {
                 case tx_caretaker_Constants::state_due:
                     $returnLatestResult = FALSE;
                     break;
                 case tx_caretaker_Constants::state_ack:
                     $returnLatestResult = TRUE;
                     break;
                 case tx_caretaker_Constants::state_ok:
                     if ($latestTestResult->getTstamp() > time() - $node->getTestInterval()) {
                         $returnLatestResult = TRUE;
                     }
                     break;
                 case tx_caretaker_Constants::state_undefined:
                 case tx_caretaker_Constants::state_warning:
                 case tx_caretaker_Constants::state_error:
                     // if due mode is 1 than retry
                     if ($node->getTestDue() == 1) {
                         $returnLatestResult = FALSE;
                     } else {
                         if ($latestTestResult->getTstamp() > time() - $node->getTestInterval()) {
                             $returnLatestResult = TRUE;
                         }
                     }
                     break;
             }
         }
         // test should not run this hour
         if (!$returnLatestResult && ($node->getStartHour() > 0 || $node->getStopHour() > 0)) {
             $localTime = localtime(time(), TRUE);
             $localHour = $localTime['tm_hour'];
             if ($localHour < $node->getStartHour() || $localHour >= $node->getStopHour()) {
                 $returnLatestResult = TRUE;
             }
         }
     }
     return $returnLatestResult;
 }