public function testSelectDbShouldReturnDatabaseInstance() { $client = new Client('localhost', 8086); $dbName = 'test-database'; $database = $client->selectDB($dbName); $this->assertInstanceOf('\\InfluxDB\\Database', $database); $this->assertEquals($dbName, $database->getName()); }
/** * @return InfluxDB\Database * @throws InfluxDB\Database\Exception */ public function connectDatabase() { if (isset($this->database)) { $this->database; } $database = $this->influxDb->selectDB($this->databaseName); try { $databaseExists = $database->exists(); } catch (ConnectException $e) { throw new \RuntimeException('InfluxDb connection error: ' . $e->getMessage()); } if (!$databaseExists) { $this->log('info', 'Database ' . $this->databaseName . ' not exists, creating'); $database->create(null, false); } return $database; }