Fixes wrong namespace for connectable

This commit is contained in:
Walter Dal Mut
2014-09-12 23:22:37 +02:00
parent eacc092deb
commit 5b5baf20dd
6 changed files with 43 additions and 8 deletions
+26 -2
View File
@@ -1,11 +1,12 @@
<?php
namespace spec\InfluxDB;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use InfluxDB\Adapter\GuzzleAdapter;
use InfluxDB\Adapter\UdpAdapter;
use InfluxDB\Adapter\AdapterInterface;
use InfluxDB\Adapter\ConnectableInterface;
class ClientSpec extends ObjectBehavior
{
@@ -13,12 +14,35 @@ class ClientSpec extends ObjectBehavior
{
$this->setAdapter($adapter);
}
function it_is_initializable()
{
$this->shouldHaveType('InfluxDB\Client');
}
function it_should_send_data(\InfluxDB\Adapter\AdapterInterface $adapter)
function it_should_be_connectable(ConnectableInterface $adapter)
{
$adapter->connect()->willReturn(true)->shouldBeCalledTimes(1);
$this->setAdapter($adapter);
$this->connect()->shouldReturn(true);
}
function it_should_be_disconnectable(ConnectableInterface $adapter)
{
$adapter->disconnect()->willReturn(true)->shouldBeCalledTimes(1);
$this->setAdapter($adapter);
$this->disconnect()->shouldReturn(true);
}
function it_should_not_call_connect(AdapterInterface $adapter)
{
$this->setAdapter($adapter);
$this->connect()->shouldReturn(false);
}
function it_should_send_data(AdapterInterface $adapter)
{
$adapter->send([[
"name" => "video.search",
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace InfluxDb\Adapter;
namespace InfluxDB\Adapter;
interface AdapterInterface
{
@@ -1,5 +1,5 @@
<?php
namespace InfluxDb\Adapter;
namespace InfluxDB\Adapter;
interface ConnectableInterface
{
+2 -1
View File
@@ -23,8 +23,8 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface
"auth" => [$this->options->getUsername(), $this->options->getPassword()],
"body" => json_encode($message)
];
$endpoint = $this->options->getHttpSeriesEndpoint();
$endpoint = $this->options->getHttpSeriesEndpoint();
return $this->httpClient->post($endpoint, $httpMessage);
}
@@ -36,6 +36,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface
"q" => $query,
]
];
if ($timePrecision) {
$options["query"]["time_precision"] = $timePrecision;
}
-1
View File
@@ -1,5 +1,4 @@
<?php
namespace InfluxDB\Adapter;
use InfluxDB\Options;
+13 -2
View File
@@ -3,6 +3,7 @@
namespace InfluxDB;
use InfluxDb\Adapter\QueryableInterface;
use InfluxDb\Adapter\ConnectableInterface;
class Client
{
@@ -21,12 +22,22 @@ class Client
public function connect()
{
return $this->getAdapter()->connect();
$result = false;
if ($this->getAdapter() instanceOf ConnectableInterface) {
$result = $this->getAdapter()->connect();
}
return $result;
}
public function disconnect()
{
return $this->getAdapter()->disconnect();
$result = false;
if ($this->getAdapter() instanceOf ConnectableInterface) {
$result = $this->getAdapter()->disconnect();
}
return $result;
}
public function mark($name, array $values)