public function handleConnectionStatus(ConnectionStatus $status) { if ($status->getType() == $status::ERROR) { throw new \ErrorException('Connection Failed'); } else { throw new SuccessException('Connection OK'); } }
/** * 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'); } }
/** * 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); } }
/** * 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; } }
/** * 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(); } }