/** * @throws ClientException */ public function testBindAndMakeHttpResponsePlusGettersSetters() { $this->request = $this->client->make('Request'); $this->request->path = '/_admin/version'; $this->request->method = HttpRequest::METHOD_GET; $this->request->send(); $this->client->bind('Response', function () { $request = $this->client->getResponse(); 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->response = $this->client->make('Response'); $this->response->build($this->request); // echo get_class($this->request); $this->assertInstanceOf('frankmayer\\ArangoDbPhpCore\\Protocols\\Http\\HttpResponseInterface', $this->response); $decodedBody = json_decode($this->response->body, true); $this->assertSame($decodedBody['server'], 'arango'); $this->assertAttributeEmpty('protocol', $this->response); // test verboseExtractStatusLine $this->response = $this->client->make('Response'); $this->response->verboseExtractStatusLine = true; $this->response->build($this->request); $this->assertAttributeNotEmpty('protocol', $this->response); $testValue = $this->response->getBatch(); $this->assertEmpty($testValue); $this->response->setBatch(true); $testValue = $this->response->getBatch(); $this->assertTrue($testValue); $testValue = $this->response->getBody(); $this->assertNotEmpty($testValue); $this->response->setBody('testBody'); $testValue = $this->response->getBody(); $this->assertEquals('testBody', $testValue); $testValue = $this->response->getHeaders(); $this->assertNotEmpty($testValue); $this->response->setHeaders('testHeaders'); $testValue = $this->response->getHeaders(); $this->assertEquals('testHeaders', $testValue); $testValue = $this->response->getRequest(); $this->assertInternalType('object', $testValue); $this->response->setRequest($testValue); $testValue = $this->response->getRequest(); $this->assertInternalType('object', $testValue); $testValue = $this->response->getStatus(); $this->assertNotEmpty($testValue); $this->response->setStatus(202); $testValue = $this->response->getStatus(); $this->assertEquals(202, $testValue); $testValue = $this->response->getProtocol(); $this->assertEquals('HTTP/1.1', $testValue); $testValue = $this->response->getStatusPhrase(); $this->assertEquals('OK', $testValue); $testValue = $this->response->getVerboseExtractStatusLine(); $this->assertEquals(true, $testValue); $this->response->setVerboseExtractStatusLine(false); $testValue = $this->response->getVerboseExtractStatusLine(); $this->assertEquals(false, $testValue); }