Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 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()] . ").");
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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) . ").");
     }
 }
Exemplo n.º 5
0
 /**
  * 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 . '"');
         }
     }
 }
Exemplo n.º 6
0
 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 . ").");
     }
 }