public function testNoConnectionPossible() { $db = new HTTP\SocketClient('127.0.0.1', 12345); try { $db->request('GET', '/' . $this->getTestDatabase()); $this->fail('Expected HTTPException.'); } catch (HTTP\HTTPException $e) { $this->assertTrue($e->getMessage() === 'Could not connect to server at 127.0.0.1:12345: \'111: Connection refused\'' || $e->getMessage() === 'Could not connect to server at 127.0.0.1:12345: \'61: Connection refused\''); } }
/** * @depends testCreateDatabase */ public function testKeepAliveConnection() { $db = new HTTP\SocketClient(); $db->setOption('keep-alive', true); $db->request('PUT', '/' . $this->getTestDatabase() . '/123', '{"_id":"123","data":"Foo"}'); $db->request('PUT', '/' . $this->getTestDatabase() . '/456', '{"_id":"456","data":"Foo"}'); $db->request('PUT', '/' . $this->getTestDatabase() . '/789', '{"_id":"789","data":"Foo"}'); $db->request('PUT', '/' . $this->getTestDatabase() . '/012', '{"_id":"012","data":"Foo"}'); $response = $db->request('GET', '/' . $this->getTestDatabase() . '/_all_docs'); $this->assertTrue($response instanceof HTTP\Response); $this->assertSame(4, $response->body['total_rows']); }