This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from lifekent/feature/offset
Offset clause for the \InfluxDB\Query\Builder class
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace InfluxDB\Test\unit\Query; | ||
|
||
use InfluxDB\Query\Builder; | ||
use InfluxDB\Test\unit\AbstractTest; | ||
|
||
class BuilderTest extends AbstractTest | ||
{ | ||
/** | ||
* @var Builder | ||
*/ | ||
protected $queryBuilder; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->queryBuilder = $this->database->getQueryBuilder(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function provideLimit() | ||
{ | ||
return [ | ||
['test_metric', 2], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideLimit | ||
* @param $from | ||
* @param $limit | ||
*/ | ||
public function testLimit($from, $limit) | ||
{ | ||
$this->assertEquals( | ||
sprintf('SELECT * FROM "%s" LIMIT %s', $from, $limit), | ||
$this->database->getQueryBuilder() | ||
->from($from) | ||
->limit($limit) | ||
->getQuery() | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function provideOffset() | ||
{ | ||
return [ | ||
['test_metric', 2], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideOffset | ||
* @param $offset | ||
* @param $from | ||
*/ | ||
public function testOffset($from, $offset) | ||
{ | ||
$this->assertEquals( | ||
sprintf('SELECT * FROM "%s" OFFSET %s', $from, $offset), | ||
$this->database->getQueryBuilder() | ||
->from($from) | ||
->offset($offset) | ||
->getQuery() | ||
); | ||
} | ||
} |