/** * This function is used to create the html document out of the response. It * calls the runTest method where all checks shouls be made. * * @see LiveTest\TestCase.TestCase::test() */ public final function test(Response $httpResponse, Request $request) { $this->httpResponse = $httpResponse; $this->request = $request; $htmlDocument = new Document($httpResponse->getBody()); $this->runTest($htmlDocument); }
public function test(Response $response, Request $request) { $result = json_decode($response->getBody()); if ($result === null) { throw new Exception("The given JSON Data is not well formed (last error: " . $this->json_errors[json_last_error()] . ")."); } }
public final function test(Response $response, Request $request) { $doc = new DOMDocument(); if (!@$doc->loadHTML($response->getBody())) { throw new \Exception("Can't create DOMDocument from HTML"); } $this->doDomTest($doc); }
public function test(Response $response, Request $request) { libxml_clear_errors(); $dom = new \DOMDocument(); @$dom->loadXML($response->getBody()); $lastError = libxml_get_last_error(); if ($lastError) { throw new Exception("The given xml file is not well formed (last error: " . str_replace("\n", '', $lastError->message) . ")."); } }
/** * This function writes the html documents to a specified directory * * @Event("LiveTest.Run.HandleResult") */ public function handleResult(Result $result, Response $response) { if (in_array($result->getStatus(), $this->logStatuses)) { $filename = $this->logPath . urlencode($result->getRequest()->getIdentifier() . '.html'); $file = new File($filename); $file->setContent($response->getBody()); try { $this->createLogDirIfNotExists($this->logPath); $file->save(); } catch (\Exception $e) { throw new ConfigurationException('Unable to write the html response to file "' . $filename . '"'); } } }
public function test(Response $response, Request $request) { // @todo same code a in the well formed test case libxml_clear_errors(); $dom = new \DOMDocument(); @$dom->loadXML($response->getBody()); $lastError = libxml_get_last_error(); if ($lastError) { throw new Exception("The given xml file is not well formed (last error: " . str_replace("\n", '', $lastError->message) . ")."); } $valid = @$dom->schemaValidate($this->xsdSchemaFile); if (!$valid) { $lastError = libxml_get_last_error(); $lastErrorMessage = str_replace("\n", '', $lastError->message); throw new Exception("The given xml file did not Validate vs. " . $this->xsdSchemaFile . " (last error: " . $lastErrorMessage . ")."); } }