1
|
|
|
<?php |
2
|
|
|
//declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Algatux\InfluxDbBundle\Tests\unit\Services\Clients; |
5
|
|
|
|
6
|
|
|
use Algatux\InfluxDbBundle\Services\Clients\InfluxDbClientFactory; |
7
|
|
|
use InfluxDB\Client; |
8
|
|
|
use InfluxDB\Database; |
9
|
|
|
use InfluxDB\Driver\Guzzle; |
10
|
|
|
use InfluxDB\Driver\UDP; |
11
|
|
|
|
12
|
|
|
class InfluxDbClientFactoryTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
const TEST_HOST = 'localhost'; |
16
|
|
|
const TEST_DB = 'udp'; |
17
|
|
|
const TEST_UDP = '4444'; |
18
|
|
|
const TEST_HTTP = '8086'; |
19
|
|
|
|
20
|
|
|
public function test_client_factory_test_exists() |
21
|
|
|
{ |
22
|
|
|
$factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP); |
23
|
|
|
$this->assertInstanceOf(InfluxDbClientFactory::class, $factory); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function test_build_udp_client_returns_a_valid_client() |
27
|
|
|
{ |
28
|
|
|
$factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP); |
29
|
|
|
$database = $factory->buildUdpClient(); |
30
|
|
|
|
31
|
|
|
$this->assertInstanceOf(Database::class, $database); |
32
|
|
|
$this->assertEquals(self::TEST_DB, $database->getName()); |
33
|
|
|
$this->assertInstanceOf(UDP::class,$database->getClient()->getDriver()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function test_build_http_client_returns_a_valid_client() |
37
|
|
|
{ |
38
|
|
|
$factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP); |
39
|
|
|
$database = $factory->buildHttpClient(); |
40
|
|
|
|
41
|
|
|
$this->assertInstanceOf(Database::class, $database); |
42
|
|
|
$this->assertEquals(self::TEST_DB, $database->getName()); |
43
|
|
|
$this->assertInstanceOf(Guzzle::class,$database->getClient()->getDriver()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
} |
47
|
|
|
|