/**
     *
     */
    public function testCreateDocumentAsync()
    {
        $createResponse = <<<TAG
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

[
  "270459873"
]
TAG;
        $body = '{ "Hello": "World" }';
        $options = ['async' => true];
        $this->connector->method('request')->willReturn($createResponse);
        $object = new Document($this->client);
        /** @var $responseObject HttpResponse */
        $response = $object->create($this->collectionNames[0], $body);
        $this->assertInstanceOf('\\frankmayer\\ArangoDbPhpCore\\Protocols\\Http\\HttpResponse', $response);
        $this->assertEquals(200, $response->status);
    }
 /**
  * Test if we can get the server version
  */
 public function testCreateUpdateDocumentAndDeleteDocumentInExistingCollection()
 {
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
     $requestBody = ['name' => 'Frank', 'bike' => 'vfr', '_key' => '1'];
     $document = new Document($this->client);
     /** @var HttpResponse $responseObject */
     $responseObject = $document->create($collectionName, $requestBody);
     $responseBody = $responseObject->body;
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertArrayNotHasKey('error', $decodedJsonBody);
     static::assertEquals($collectionName . '/1', $decodedJsonBody['_id']);
     $requestBody = ['name' => 'Mike'];
     $document = new Document($this->client);
     $responseObject = $document->update($collectionName . '/1', $requestBody);
     $responseBody = $responseObject->body;
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertArrayNotHasKey('error', $decodedJsonBody);
     static::assertEquals($collectionName . '/1', $decodedJsonBody['_id']);
     $document = new Document($this->client);
     $responseObject = $document->get($collectionName . '/1', $requestBody);
     $responseBody = $responseObject->body;
     static::assertArrayHasKey('bike', json_decode($responseBody, true));
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertEquals('Mike', $decodedJsonBody['name']);
     static::assertEquals($collectionName . '/1', $decodedJsonBody['_id']);
     $responseObject = $document->delete($collectionName . '/1');
     $responseBody = $responseObject->body;
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertArrayNotHasKey('error', $decodedJsonBody);
     // Try to delete a second time .. should throw an error
     $responseObject = $document->delete($collectionName . '/1');
     $responseBody = $responseObject->body;
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertArrayHasKey('error', $decodedJsonBody);
     static::assertEquals(true, $decodedJsonBody['error']);
     static::assertEquals(404, $decodedJsonBody['code']);
     static::assertEquals(1202, $decodedJsonBody['errorNum']);
 }
 /**
  *
  */
 public function testCreateCollectionAndStoredAsyncDocumentCreation()
 {
     $job = new Async($this->client);
     $job->deleteJobResult('all');
     // todo 1 Frank Write real test for deleting job results with stamp
     $job->deleteJobResult('all', time());
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
     $collectionOptions = ['waitForSync' => true];
     $collection = new Collection($this->client);
     /** @var $responseObject HttpResponse */
     $responseObject = $collection->create($collectionName, $collectionOptions);
     $body = $responseObject->body;
     $decodedJsonBody = json_decode($body, true);
     static::assertEquals(200, $decodedJsonBody['code']);
     static::assertEquals($collectionName, $decodedJsonBody['name']);
     $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
     $requestBody = ['name' => 'frank', '_key' => '1'];
     $document = new Document($this->client);
     $responseObject = $document->create($collectionName, $requestBody, null, ['async' => 'store']);
     static::assertEquals(202, $responseObject->status);
     sleep(1);
     $jobId = $responseObject->headers['X-Arango-Async-Id'][0];
     $jobList = $job->listJobResults('done', 1);
     $jobArray = json_decode($jobList->body, true);
     static::assertTrue(in_array($jobId, $jobArray, true));
     $jobResult = $job->fetchJobResult($responseObject->headers['X-Arango-Async-Id'][0]);
     static::assertSame($jobResult->headers['X-Arango-Async-Id'], $responseObject->headers['X-Arango-Async-Id']);
     static::assertArrayHasKey('X-Arango-Async-Id', $jobResult->headers);
     $document = new Document($this->client);
     $responseObject = $document->get($collectionName . '/1', $requestBody);
     $responseBody = $responseObject->body;
     $decodedJsonBody = json_decode($responseBody, true);
     static::assertEquals($collectionName . '/1', $decodedJsonBody['_id']);
 }
    /**
     *
     */
    public function testGetAllDocuments()
    {
        $deleteCollectionResponse = <<<TAG
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "documents" : [
    "/_api/document/products/1495340880",
    "/_api/document/products/1494685520",
    "/_api/document/products/1495013200"
  ]
}
TAG;
        $options = ['excludeSystem' => true];
        $this->connector->method('request')->willReturn($deleteCollectionResponse);
        $object = new Document($this->client);
        /** @var $responseObject HttpResponse */
        $response = $object->getAll($this->collectionNames[0], $options);
        $this->assertInstanceOf('\\frankmayer\\ArangoDbPhpCore\\Protocols\\Http\\HttpResponse', $response);
        $this->assertEquals(200, $response->status);
    }