public function testGetTime()
 {
     $timer = new Timer();
     time_nanosleep(0, 200000000);
     $result1 = $timer->getTime();
     time_nanosleep(0, 300000000);
     $result2 = $timer->getTime(true);
     time_nanosleep(0, 100000000);
     $result3 = $timer->getTime();
     $this->assertTrue(0.2 <= $result1 && $result1 <= 0.205, $result1);
     $this->assertTrue(0.5 <= $result2 && $result2 <= 0.505, $result2);
     $this->assertTrue(0.1 <= $result3 && $result3 <= 0.105, $result3);
 }
 /**
  * Action to show the request form and result of the previously submitted request
  * @return null
  */
 public function indexAction()
 {
     $request = null;
     $response = null;
     $responseString = null;
     $time = null;
     $form = new ClientForm($this->request->getBasePath());
     if ($form->isSubmitted()) {
         try {
             $form->validate();
             $server = $form->getServer();
             $method = $form->getMethod();
             $parameters = $form->getParameters();
             $timer = new Timer();
             $request = $this->getXmlrpcRequest($method, $parameters);
             $client = new Client($server);
             $response = $client->invoke($request);
             $time = $timer->getTime();
         } catch (XmlRpcInvalidResponseException $exception) {
             Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
             $responseString = $exception->getResponseString();
             $previous = $exception->getPrevious();
             if ($previous) {
                 $message = $previous->getMessage();
             } else {
                 $message = $exception->getMessage();
             }
             $error = new ValidationError(self::TRANSLATION_ERROR_RESPONSE, 'Response error: %error%', array('error' => $message));
             $validationException = new ValidationException();
             $validationException->addErrors(ClientForm::FIELD_SERVER, array($error));
             $form->setValidationException($validationException);
         } catch (XmlRpcException $exception) {
             Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
             $error = new ValidationError(self::TRANSLATION_ERROR_CONNECTION, 'Connection error: %error%', array('error' => $exception->getMessage()));
             $validationException = new ValidationException();
             $validationException->addErrors(ClientForm::FIELD_SERVER, array($error));
             $form->setValidationException($validationException);
         } catch (ValidationException $exception) {
             $form->setValidationException($exception);
         }
     }
     $view = new ClientView($form, $request, $response, $responseString, $time);
     $this->response->setView($view);
 }