diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7c33ebc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php +script: phpunit + +php: + - 5.4 + - 5.5 + +before_script: + - curl -s http://getcomposer.org/installer | php + - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb + - sudo dpkg -i influxdb_latest_amd64.deb + - php composer.phar install diff --git a/lib/InfluxPHP/BaseHTTP.php b/lib/InfluxPHP/BaseHTTP.php index aeb5f04..40e0b59 100644 --- a/lib/InfluxPHP/BaseHTTP.php +++ b/lib/InfluxPHP/BaseHTTP.php @@ -70,7 +70,7 @@ class BaseHTTP //$type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); curl_close($ch); if ($status[0] != 2) { - throw new \Exception($response); + throw new \RuntimeException($response); } return $json ? json_decode($response, true) : $response; } @@ -85,7 +85,7 @@ class BaseHTTP return $this->execCurl($ch); } - protected function get($url, Array $args) + protected function get($url, Array $args = []) { $ch = $this->getCurl($url, $args); return $this->execCurl($ch, true); diff --git a/lib/InfluxPHP/DB.php b/lib/InfluxPHP/DB.php index 9d63485..a76dd1e 100644 --- a/lib/InfluxPHP/DB.php +++ b/lib/InfluxPHP/DB.php @@ -50,6 +50,16 @@ class DB extends BaseHTTP $this->base = "db/$name/"; } + public function getName() + { + return $this->name; + } + + public function drop() + { + return $this->client->deleteDatabase($this->name); + } + public function insert($name, Array $data) { $points = []; diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..9ac75c2 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,35 @@ + + + + + + + + tests/ + + + + + + tests/ + lib/ + + + +