2022-08-12 13:47:03 +00:00
|
|
|
<?php
|
2022-08-15 20:28:25 +00:00
|
|
|
|
2022-08-12 13:47:03 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2022-08-15 20:28:25 +00:00
|
|
|
namespace Tests\Functions;
|
|
|
|
|
|
|
|
|
|
use DateTime;
|
2022-08-12 13:47:03 +00:00
|
|
|
use Arendsen\FluxQueryBuilder\Functions\Range;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
2022-08-15 20:28:25 +00:00
|
|
|
final class RangeFunctionTest extends TestCase
|
|
|
|
|
{
|
2022-08-12 13:47:03 +00:00
|
|
|
public function testOnlyStartOption()
|
|
|
|
|
{
|
2022-08-12 21:25:03 +00:00
|
|
|
$expression = new Range(
|
|
|
|
|
new DateTime('2022-08-12 18:00:00')
|
|
|
|
|
);
|
2022-08-12 13:47:03 +00:00
|
|
|
|
2022-08-12 21:25:03 +00:00
|
|
|
$query = '|> range(start: time(v: 2022-08-12T18:00:00Z)) ';
|
2022-08-12 13:47:03 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals($query, $expression->__toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testWithStopOption()
|
|
|
|
|
{
|
2022-08-12 21:25:03 +00:00
|
|
|
$expression = new Range(
|
|
|
|
|
new DateTime('2022-08-12 18:00:00'),
|
|
|
|
|
new DateTime('2022-08-12 20:00:00')
|
|
|
|
|
);
|
2022-08-12 13:47:03 +00:00
|
|
|
|
2022-08-12 21:25:03 +00:00
|
|
|
$query = '|> range(start: time(v: 2022-08-12T18:00:00Z), stop: time(v: 2022-08-12T20:00:00Z)) ';
|
2022-08-12 13:47:03 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals($query, $expression->__toString());
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 15:49:25 +00:00
|
|
|
public function testRangeInBetween()
|
|
|
|
|
{
|
2022-08-12 21:25:03 +00:00
|
|
|
$expression = new Range(
|
|
|
|
|
new DateTime('2022-08-12 17:31:00'),
|
|
|
|
|
new DateTime('2022-08-12 18:31:00'),
|
|
|
|
|
);
|
2022-08-12 15:49:25 +00:00
|
|
|
|
|
|
|
|
$expected = '|> range(start: time(v: 2022-08-12T17:31:00Z), stop: time(v: 2022-08-12T18:31:00Z)) ';
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $expression->__toString());
|
|
|
|
|
}
|
2022-08-15 20:28:25 +00:00
|
|
|
}
|