/** * @expectedException Elasticsearch\Common\Exceptions\Curl\CouldNotResolveHostException */ public function test5xxErrorBadHost() { $hostDetails = array('host' => 'localhost5', 'port' => 9200); $connectionParams['guzzleClient'] = new Client(); $log = m::mock('\\Monolog\\Logger')->shouldReceive('error')->once()->getMock(); $connection = new GuzzleConnection($hostDetails, $connectionParams, $log, $log); $ret = $connection->performRequest('GET', '/'); }
/** * @group ignore */ public function test4xxErrorInvalidIndexAndQueryBody() { $hostDetails = array('host' => 'localhost', 'port' => 9200); $connectionParams['guzzleClient'] = new Client(); $log = m::mock('\\Monolog\\Logger')->shouldReceive('debug')->times(6)->getMock()->shouldReceive('info')->times(4)->getMock(); $connection = new GuzzleConnection($hostDetails, $connectionParams, $log, $log); $body = '{"testsetting":"123"}'; /* The index _doesnotexist is used with an underscore because ES won't create it...invalid. */ $ret = $connection->performRequest('POST', '/_doesnotexist', null, $body); $this->assertEquals(400, $ret['status']); $expectedURI = 'http://localhost:9200/_doesnotexist'; $this->assertEquals($expectedURI, $ret['info']['url']); // Best we can do to make sure the post actually posted. $this->assertEquals(strlen($body), $ret['info']['size_upload']); }