2015-06-18 14:59:00 +02:00
|
|
|
<?php
|
|
|
|
|
2015-06-23 09:19:24 +02:00
|
|
|
namespace InfluxDB\Test;
|
2015-06-18 14:59:00 +02:00
|
|
|
|
2015-06-23 09:19:24 +02:00
|
|
|
use InfluxDB\Client;
|
2015-07-21 00:34:08 +02:00
|
|
|
use InfluxDB\Driver\Guzzle;
|
2015-06-18 14:59:00 +02:00
|
|
|
|
2015-08-02 22:13:17 +02:00
|
|
|
class ClientTest extends AbstractTest
|
2015-06-18 14:59:00 +02:00
|
|
|
{
|
|
|
|
|
2015-08-02 22:13:17 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
2015-06-18 14:59:00 +02:00
|
|
|
/** @var Client $client */
|
|
|
|
protected $client = null;
|
2015-07-21 00:34:08 +02:00
|
|
|
|
2015-06-18 14:59:00 +02:00
|
|
|
public function testBaseURl()
|
|
|
|
{
|
2015-07-03 17:20:35 +02:00
|
|
|
$client = new Client('localhost', 8086);
|
|
|
|
|
2015-07-21 00:34:08 +02:00
|
|
|
$this->assertEquals($client->getBaseURI(), 'http://localhost:8086');
|
2015-06-18 14:59:00 +02:00
|
|
|
}
|
2015-07-03 17:29:25 +02:00
|
|
|
|
|
|
|
public function testSelectDbShouldReturnDatabaseInstance()
|
|
|
|
{
|
|
|
|
$client = new Client('localhost', 8086);
|
|
|
|
|
|
|
|
$dbName = 'test-database';
|
2015-07-21 00:34:08 +02:00
|
|
|
$database = $client->selectDB($dbName);
|
2015-07-03 17:29:25 +02:00
|
|
|
|
2015-07-21 00:34:08 +02:00
|
|
|
$this->assertInstanceOf('\InfluxDB\Database', $database);
|
2015-07-03 17:29:25 +02:00
|
|
|
|
2015-07-21 00:34:08 +02:00
|
|
|
$this->assertEquals($dbName, $database->getName());
|
2015-07-03 17:29:25 +02:00
|
|
|
}
|
2015-07-06 15:58:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
2015-07-21 00:34:08 +02:00
|
|
|
public function testGuzzleQuery()
|
2015-07-06 15:58:29 +02:00
|
|
|
{
|
|
|
|
$client = new Client('localhost', 8086);
|
|
|
|
$query = "some-bad-query";
|
|
|
|
|
|
|
|
$bodyResponse = file_get_contents(dirname(__FILE__) . '/result.example.json');
|
2015-08-02 22:13:17 +02:00
|
|
|
$httpMockClient = $this->buildHttpMockClient($bodyResponse);
|
2015-07-06 15:58:29 +02:00
|
|
|
|
2015-07-21 00:34:08 +02:00
|
|
|
$client->setDriver(new Guzzle($httpMockClient));
|
2015-07-06 15:58:29 +02:00
|
|
|
|
|
|
|
/** @var \InfluxDB\ResultSet $result */
|
|
|
|
$result = $client->query(null, $query);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\InfluxDB\ResultSet', $result);
|
|
|
|
}
|
|
|
|
|
2015-06-18 14:59:00 +02:00
|
|
|
}
|