/**
  * @throws ClientException
  */
 public function testBindAndMakeHttpRequest()
 {
     $this->client->bind('Request', function () {
         $request = $this->client->getRequest();
         return $request;
     });
     // And here's how one gets an HttpRequest object through the IOC.
     // Note that the type-name 'httpRequest' is the name we bound our HttpRequest class creation-closure to. (see above)
     $this->request = $this->client->make('Request');
     $this->assertInstanceOf('frankmayer\\ArangoDbPhpCore\\Protocols\\Http\\AbstractHttpRequest', $this->request);
     $testValue = $this->request->getAddress();
     $this->assertNull($testValue);
     $this->request->setAddress('testAddress');
     $testValue = $this->request->getAddress();
     $this->assertEquals('testAddress', $testValue);
     $testValue = $this->request->getBody();
     $this->assertNull($testValue);
     $this->request->setBody('testBody');
     $testValue = $this->request->getBody();
     $this->assertEquals('testBody', $testValue);
     $testValue1 = $this->request->getClient();
     $this->assertInstanceOf('\\frankmayer\\ArangoDbPhpCore\\Client', $testValue1);
     $this->request->setClient($this->client);
     $testValue1 = $this->request->getClient();
     $this->assertEquals($this->client, $testValue1);
     $testValue1 = $this->request->getConnector();
     $this->assertNull($testValue1);
     $this->request->setConnector($this->connector);
     $testValue1 = $this->request->getConnector();
     $this->assertEquals($this->connector, $testValue1);
     $testValue = $this->request->getHeaders();
     $this->assertEmpty($testValue);
     $this->request->setHeaders('testHeaders');
     $testValue = $this->request->getHeaders();
     $this->assertEquals('testHeaders', $testValue);
     $testValue = $this->request->getMethod();
     $this->assertNull($testValue);
     $this->request->setMethod('testMethod');
     $testValue = $this->request->getMethod();
     $this->assertEquals('testMethod', $testValue);
     $testValue1 = $this->request->getOptions();
     $this->assertEmpty($testValue1);
     $this->request->setOptions(['testOption' => 'testVal']);
     $testValue = $this->request->getOptions();
     $this->assertArrayHasKey('testOption', $testValue);
     $this->request->setOptions($testValue1);
     $testValue = $this->request->getOptions();
     $this->assertEquals($testValue1, $testValue);
     $testValue = $this->request->getPath();
     $this->assertNull($testValue);
     $this->request->setPath('testPath');
     $testValue = $this->request->getPath();
     $this->assertEquals('testPath', $testValue);
     $testValue = $this->request->getResponse();
     $this->assertNull($testValue);
     $this->request->setResponse('testResponse');
     $testValue = $this->request->getResponse();
     $this->assertEquals('testResponse', $testValue);
 }
 /**
  *
  */
 public function setUp()
 {
     $connector = new Connector();
     $this->connector = $connector;
     $this->client = getClient($connector);
     $this->client->bind('Request', function () {
         $request = $this->client->getRequest();
         return $request;
     });
 }
 /**
  * Test if we can get the server version
  */
 public function testDeleteDatabaseWithoutApiClasses()
 {
     $databaseName = 'ArangoDB-PHP-Core-DatabaseTestSuite-Database';
     $databaseOptions = [];
     $options = $databaseOptions;
     $this->client->bind('Request', function () {
         return $this->client->getRequest();
     });
     $request = $this->client->make('Request');
     $request->options = $options;
     $request->path = $this->client->fullDatabasePath . self::API_DATABASE . '/' . $databaseName;
     $request->method = self::METHOD_DELETE;
     $responseObject = $request->send();
     $body = $responseObject->body;
     static::assertArrayHasKey('code', json_decode($body, true));
     $decodedJsonBody = json_decode($body, true);
     static::assertEquals(200, $decodedJsonBody['code']);
 }
 /**
  * Test if we can get the server version
  */
 public function testDeleteCollectionWithoutApiClasses()
 {
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
     $collectionOptions = ['waitForSync' => true];
     $options = $collectionOptions;
     $this->client->bind('Request', function () {
         return $this->client->getRequest();
     });
     $request = $this->client->make('Request');
     $request->options = $options;
     $request->path = $this->client->fullDatabasePath . self::API_COLLECTION . '/' . $collectionName;
     $request->method = self::METHOD_DELETE;
     $responseObject = $request->send();
     $body = $responseObject->body;
     static::assertArrayHasKey('code', json_decode($body, true));
     $decodedJsonBody = json_decode($body, true);
     static::assertEquals(200, $decodedJsonBody['code']);
 }
 /**
  * Test if we can get the server version
  */
 public function testSync()
 {
     $collectionParameters = [];
     $this->client->bind('Request', function () {
         return $this->client->getRequest();
     });
     $query = 'RETURN SLEEP(1)';
     $statement = ['query' => $query];
     // And here's how one gets an HttpRequest object through the IOC.
     // Note that the type-name 'httpRequest' is the name we bound our HttpRequest class creation-closure to. (see above)
     $request = $this->client->make('Request');
     $request->body = $statement;
     //        $request->connectorOptions = ['future' => true];
     $request->body = self::array_merge_recursive_distinct($request->body, $collectionParameters);
     $request->body = json_encode($request->body);
     $request->path = $this->client->fullDatabasePath . self::URL_CURSOR;
     $request->method = self::METHOD_POST;
     $responseObject = $request->send();
     $body = $responseObject->body;
     static::assertArrayHasKey('code', json_decode($body, true));
     $decodedJsonBody = json_decode($body, true);
     static::assertEquals(201, $decodedJsonBody['code']);
 }
 /**
  * @throws ClientException
  */
 public function tearDown()
 {
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
     $collectionOptions = ["waitForSync" => true];
     $options = $collectionOptions;
     $this->client->bind('Request', function () {
         $request = $this->client->getRequest();
         return $request;
     });
     $request = $this->client->make('Request');
     $request->options = $options;
     $request->path = $this->client->fullDatabasePath . self::API_COLLECTION . '/' . $collectionName;
     $request->method = self::METHOD_DELETE;
     /** @var HttpResponse $responseObject */
     $responseObject = $request->send();
     $body = $responseObject->body;
     $this->assertArrayHasKey('code', json_decode($body, true));
     $decodedJsonBody = json_decode($body, true);
     $this->assertEquals(200, $decodedJsonBody['code']);
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-NonExistingCollection';
     $collection = new Collection($this->client);
     /** @var $responseObject HttpResponse */
     $collection->drop($collectionName);
 }