// show error message if (!$runner->getAuth()->isAuthenticated()) { throw new Exception("Authentication problem. You have to login first."); } /** * Execute one individual test and return its result * in JSON format. We reach this point only in AJAX calls from * already rendered testing page. */ $options = $_GET; /** * '_' param is automatically added by jQuery with current time in miliseconds, * when we call $.ajax function with cache = false. We unset it to have * no exception in phpRack_Test::setAjaxOptions() */ unset($options['_']); $label = $options[PHPRACK_AJAX_TAG]; unset($options[PHPRACK_AJAX_TAG]); $token = $options[PHPRACK_AJAX_TOKEN]; unset($options[PHPRACK_AJAX_TOKEN]); header('Content-Type: application/json'); throw new Exception($runner->run($label, $token, $options)); } catch (Exception $e) { /** * Here we render the content prepared above. It's not * an exception actually, but a content prepared. Such * design is not perfect and needs refactoring sooner or * later... */ echo $e->getMessage(); }
* why the line is commented for now. */ // header('Content-Type: application/xhtml+xml'); throw new Exception($view->render()); } // show error message if (!$runner->getAuth()->isAuthenticated()) { throw new Exception("Authentication problem. You have to login first."); } /** * Execute one individual test and return its result * in JSON format. We reach this point only in AJAX calls from * already rendered testing page. */ $options = $_GET; /** * '_' param is automatically added by jQuery with current time in miliseconds, * when we call $.ajax function with cache = false. We unset it to have * no exception in phpRack_Test::setAjaxOptions() */ unset($options['_']); $fileName = $options[PHPRACK_AJAX_TAG]; unset($options[PHPRACK_AJAX_TAG]); $token = $options[PHPRACK_AJAX_TOKEN]; unset($options[PHPRACK_AJAX_TOKEN]); header('Content-Type: application/json'); throw new Exception($runner->run($fileName, $token, $options)); } catch (Exception $e) { $content = $e->getMessage(); echo $content; }