function test_getResultRange()
 {
     $instance = new tx_caretaker_InstanceNode(1, 'title', false, '');
     $test = new tx_caretaker_TestNode(0, 'title', $instance, 'tx_caretaker_ping', '');
     $test_result_repository = tx_caretaker_TestResultRepository::getInstance();
     $result_range = $test_result_repository->getRangeByNode($test, time() - 10000, time());
     $this->assertNotNull(count($result_range), 'there are tests found in range');
 }
 /**
  *
  * @param tx_caretaker_TestServiceInterface $testService
  * @param tx_caretaker_TestNode $node
  * @param tx_caretaker_NodeResult $latestTestResult
  * @param array $options
  * @return tx_caretaker_NodeResult
  */
 protected function executeTestServiceRun($testService, $node, $latestTestResult, $options)
 {
     // check wether the test can be executed
     if ($testService && $testService->isExecutable()) {
         try {
             $result = $testService->runTest();
         } catch (Exception $e) {
             $result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage);
         }
         // retry if not ok and retrying is enabled
         if ($result->getState() != 0 && $node->getTestRetry() > 0) {
             $round = 0;
             while ($round < $node->getTestRetry() && $result->getState() != 0) {
                 // TODO make sleep time between retry configurable
                 sleep(1);
                 try {
                     $result = $testService->runTest();
                 } catch (Exception $e) {
                     $result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage);
                 }
                 $round++;
             }
             $result->addSubMessage(new tx_caretaker_ResultMessage('LLL:EXT:caretaker/locallang_fe.xml:retry_info', array('number' => $round)));
         }
         // save to repository after reading the previous result
         $resultRepository = tx_caretaker_TestResultRepository::getInstance();
         $resultRepository->saveTestResultForNode($node, $result);
         // trigger notification
         $node->notify('updatedTestResult', $result, $latestTestResult);
         return $result;
     } else {
         $result = tx_caretaker_TestResult::undefined();
         $result->addSubMessage(new tx_caretaker_ResultMessage('test service was not executable this time so the cached result is used'));
         $node->notify('cachedTestResult', $result, $latestTestResult);
         return $latestTestResult;
     }
 }
 /**
  * @param tx_caretaker_TestResult $result
  * @return tx_caretaker_TestResult
  */
 public function getPreviousDifferingResult($result)
 {
     $testResultRepository = tx_caretaker_TestResultRepository::getInstance();
     return $testResultRepository->getPreviousDifferingResult($this, $result);
 }
 /**
  * Get the TestResultRange for the Offset and Limit
  *
  * @see caretaker/trunk/classes/nodes/tx_caretaker_AbstractNode#getTestResultRange()
  * @param int $offset
  * @param boolean $graph True by default. Used in the result range repository the specify the handling of the last result. For more information see tx_caretaker_testResultRepository.
  * @return tx_caretaker_TestResultRange
  */
 public function getTestResultRangeByOffset($offset = 0, $limit = 10)
 {
     $test_result_repository = tx_caretaker_TestResultRepository::getInstance();
     $resultRange = $test_result_repository->getResultRangeByNodeAndOffset($this, $offset, $limit);
     return $resultRange;
 }