ResultSet::getPoints empty parameters

This commit is contained in:
danibrutal
2015-06-18 14:59:00 +02:00
parent 7d91bb0519
commit 033d593d51
3 changed files with 44 additions and 3 deletions

View File

@@ -55,7 +55,11 @@ class ResultSet
$points = array(); $points = array();
foreach ($this->getSeries() as $serie) { foreach ($this->getSeries() as $serie) {
if ($serie['name'] == $metricName || array_intersect($tags, $serie['tags'])) {
if ((empty($metricName) && empty($tags))
|| $serie['name'] == $metricName
|| array_intersect($tags, $serie['tags'])
) {
$points = array_merge($points, $this->getPointsFromSerie($serie)); $points = array_merge($points, $this->getPointsFromSerie($serie));
} }
} }
@@ -68,10 +72,10 @@ class ResultSet
* *
* results is an array of objects, one for each query, * results is an array of objects, one for each query,
* each containing the keys for a series * each containing the keys for a series
* *
* @return array $series * @return array $series
*/ */
private function getSeries() public function getSeries()
{ {
$pickSeries = function ($object) { $pickSeries = function ($object) {
return $object['series']; return $object['series'];

20
tests/unit/ClientTest.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
namespace Leaseweb\InfluxDB\Test;
use Leaseweb\InfluxDB\Client;
class ClientTest extends \PHPUnit_Framework_TestCase
{
/** @var Client $client */
protected $client = null;
public function testBaseURl()
{
$this->assertTrue(
true
);
}
}

View File

@@ -40,6 +40,23 @@ EOD;
new ResultSet($errorResult); new ResultSet($errorResult);
} }
/**
* We can get points from measurement
*/
public function testGetPoints()
{
$expectedNumberOfPoints = 3;
$points = $this->resultSet->getPoints();
$this->assertTrue(
is_array($points)
);
$this->assertCount($expectedNumberOfPoints, $points);
}
/** /**
* We can get points from measurement * We can get points from measurement
*/ */