IntegrationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace GraphAware\NeoClient\Formatter\Tests\Integration;
  3. use GraphAware\NeoClient\Formatter\ResponseFormattingService;
  4. use GuzzleHttp\Psr7\Response as HttpResponse;
  5. use Neoxygen\NeoClient\ClientBuilder;
  6. class IntegrationTest extends \PHPUnit_Framework_TestCase
  7. {
  8. public function testNeoClientIntegration()
  9. {
  10. $client = ClientBuilder::create()
  11. ->addConnection('default', 'http', 'localhost', 7474, true, 'neo4j', 'veryCoolMax')
  12. ->setAutoFormatResponse(true)
  13. ->setResponseFormatterClass('GraphAware\NeoClient\Formatter\Adapter')
  14. ->enableNewFormattingService()
  15. ->build();
  16. $response = $client->sendCypherQuery('MATCH (n) RETURN count(n) as nodesCount');
  17. $this->assertInstanceOf('GraphAware\NeoClient\Formatter\Response', $response);
  18. }
  19. public function testResponseIsFormatted()
  20. {
  21. $service = new ResponseFormattingService();
  22. $httpresponse = $this->loadResponse(__DIR__.'/../_resources/response-profile.json');
  23. $response = $service->formatResponse($httpresponse);
  24. $this->assertInstanceOf('GraphAware\NeoClient\Formatter\Response', $response);
  25. }
  26. /**
  27. * @param $file
  28. * @return \GuzzleHttp\Psr7\Response
  29. */
  30. private function loadResponse($file)
  31. {
  32. $body = file_get_contents($file);
  33. $httpResponse = new HttpResponse(200, array(), $body);
  34. return $httpResponse;
  35. }
  36. }