setHost() public method

public setHost ( string $host )
$host string
コード例 #1
0
 /**
  * @group unit
  */
 public function testToString()
 {
     $path = 'test';
     $method = Request::POST;
     $query = array('no' => 'params');
     $data = array('key' => 'value');
     $connection = new Connection();
     $connection->setHost($this->_getHost());
     $connection->setPort('9200');
     $request = new Request($path, $method, $data, $query, $connection);
     $data = $request->toArray();
     $this->assertInternalType('array', $data);
     $this->assertArrayHasKey('method', $data);
     $this->assertArrayHasKey('path', $data);
     $this->assertArrayHasKey('query', $data);
     $this->assertArrayHasKey('data', $data);
     $this->assertArrayHasKey('connection', $data);
     $this->assertEquals($request->getMethod(), $data['method']);
     $this->assertEquals($request->getPath(), $data['path']);
     $this->assertEquals($request->getQuery(), $data['query']);
     $this->assertEquals($request->getData(), $data['data']);
     $this->assertInternalType('array', $data['connection']);
     $this->assertArrayHasKey('host', $data['connection']);
     $this->assertArrayHasKey('port', $data['connection']);
     $this->assertEquals($request->getConnection()->getHost(), $data['connection']['host']);
     $this->assertEquals($request->getConnection()->getPort(), $data['connection']['port']);
     $string = $request->toString();
     $this->assertInternalType('string', $string);
     $string = (string) $request;
     $this->assertInternalType('string', $string);
 }
コード例 #2
0
ファイル: ThriftTest.php プロジェクト: kskod/Elastica
 /**
  * @expectedException \Elastica\Exception\ResponseException
  */
 public function testInvalidElasticRequest()
 {
     $connection = new Connection();
     $connection->setHost('localhost');
     $connection->setPort(9500);
     $connection->setTransport('Thrift');
     $client = new Client();
     $client->addConnection($connection);
     $index = new Index($client, 'missing_index');
     $index->getStatus();
 }
コード例 #3
0
 /**
  * @group functional
  * @expectedException \Elastica\Exception\ResponseException
  */
 public function testInvalidElasticRequest()
 {
     $this->_checkPlugin();
     $connection = new Connection();
     $connection->setHost($this->_getHost());
     $connection->setPort(9500);
     $connection->setTransport('Thrift');
     $client = $this->_getClient();
     $client->addConnection($connection);
     $index = new Index($client, 'missing_index');
     $index->getStatus();
 }
コード例 #4
0
 public function testConvertRequestToCurlCommand()
 {
     $path = 'test';
     $method = Request::POST;
     $query = array('no' => 'params');
     $data = array('key' => 'value');
     $connection = new Connection();
     $connection->setHost('localhost');
     $connection->setPort('9200');
     $request = new Request($path, $method, $data, $query, $connection);
     $curlCommand = Util::convertRequestToCurlCommand($request);
     $expected = 'curl -XPOST \'http://localhost:9200/test?no=params\' -d \'{"key":"value"}\'';
     $this->assertEquals($expected, $curlCommand);
 }