Example #1
0
 /**
  * Returns the json answer of the web server.
  *
  * failure:
  * {
  *   status: "failure",
  *   message: "unknown api key"
  * }
  *
  * success:
  * {
  *   status: "success"
  * }
  */
 private function getJsonResponse($endpoint, \JsonSerializable $object)
 {
     $objectJson = json_encode($object->jsonSerialize());
     try {
         $response = $this->httpClient->request('POST', $endpoint, ['body' => $objectJson]);
     } catch (\Exception $e) {
         $ex = new KoalamonException('Error sending event to Koalamon server.');
         $ex->setPayload($objectJson);
         $ex->setUrl($endpoint);
         throw $ex;
     }
     $responseStatus = json_decode($response->getBody());
     return $responseStatus;
 }
 public function testGetContent()
 {
     $content = $this->adapter->getContent('http://www.google.com');
     $this->assertNotNull($content);
     $this->assertContains('google', $content);
 }