コード例 #1
0
 public function handleConnectionStatus(ConnectionStatus $status)
 {
     if ($status->getType() == $status::ERROR) {
         throw new \ErrorException('Connection Failed');
     } else {
         throw new SuccessException('Connection OK');
     }
 }
コード例 #2
0
ファイル: ProgressBar.php プロジェクト: NilsLangner/LiveTest
 /**
  * This function echoes a E if the connection failed.
  *
  * @Event("LiveTest.Run.HandleConnectionStatus")
  *
  * @param ConnectionStatus
  */
 public function handleConnectionStatus(ConnectionStatus $connectionStatus)
 {
     if ($connectionStatus->getType() == ConnectionStatus::ERROR) {
         $this->echoChar('E');
     }
 }
コード例 #3
0
ファイル: Run.php プロジェクト: NilsLangner/LiveTest
 /**
  * This function sends a http request and assigns the response to the test cases.
  *
  * @notify LiveTest.Run.HandleConnectionStatus
  *
  * @param TestSet $testSet
  */
 private function runTestSet(TestSet $testSet, $sessionName)
 {
     $connectionStatusValue = ConnectionStatus::SUCCESS;
     $connectionStatusMessage = '';
     $request = $testSet->getRequest();
     $this->eventDispatcher->simpleNotify('LiveTest.Run.PrepareRequest', array('request' => $request));
     try {
         $client = $this->httpClients[$sessionName];
         // the client must be reset, otherwise curl dies
         $client->resetParameters();
         $response = $client->request($request);
     } catch (\Zend\Http\Exception $e) {
         $connectionStatusValue = ConnectionStatus::ERROR;
         $connectionStatusMessage = $e->getMessage();
     }
     $connectionStatus = new ConnectionStatus($connectionStatusValue, $request, $connectionStatusMessage);
     if (isset($response)) {
         $connectionStatus->setResponse($response);
     }
     $this->eventDispatcher->simpleNotify('LiveTest.Run.HandleConnectionStatus', array('connectionStatus' => $connectionStatus));
     if ($connectionStatusValue === ConnectionStatus::SUCCESS) {
         $this->runTests($testSet, $response, $sessionName);
     }
 }
コード例 #4
0
ファイル: Report.php プロジェクト: NilsLangner/LiveTest
 /**
  * Collect all information about the connection errors.
  *
  * @Event("LiveTest.Run.HandleConnectionStatus")
  *
  * @param ConnectionStatus $status
  */
 public function handleConnectionStatus(ConnectionStatus $connectionStatus)
 {
     if ($connectionStatus->getType() == ConnectionStatus::ERROR) {
         $this->connectionStatuses[] = $connectionStatus;
     }
 }
コード例 #5
0
ファイル: Verbose.php プロジェクト: NilsLangner/LiveTest
 /**
  * Echoes the connection status
  *
  * @Event("LiveTest.Run.HandleConnectionStatus")
  *
  * @param ConnectionStatus $status
  */
 public function handleConnectionStatus(ConnectionStatus $connectionStatus)
 {
     if ($this->verbose) {
         echo "\n  - Connection: " . $connectionStatus->getRequest()->getUri() . " - " . $connectionStatus->getType();
     }
 }