2022-08-31 15:32:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
declare( strict_types=1 );
|
2022-08-31 15:32:13 +00:00
|
|
|
|
|
|
|
|
namespace Tests\Functions;
|
|
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
use Hosterra\FluxBuilder\Functions\Window;
|
2022-08-31 15:32:13 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
final class WindowFunctionTest extends TestCase {
|
|
|
|
|
public function testSimpleWindow() {
|
|
|
|
|
$expression = new Window( '20s' );
|
|
|
|
|
|
|
|
|
|
$query = '|> window(every: 20s) ';
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $query, $expression->__toString() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAllParameters() {
|
|
|
|
|
$expression = new Window( '20s', [
|
|
|
|
|
'period' => 'every',
|
|
|
|
|
'offset' => '0s',
|
|
|
|
|
'location' => 'location',
|
|
|
|
|
'timeColumn' => '_time',
|
|
|
|
|
'startColumn' => '_start',
|
|
|
|
|
'stopColumn' => '_stop',
|
|
|
|
|
'createEmpty' => true
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$query = '|> window(every: 20s, period: every, offset: 0s, location: "location", ' .
|
|
|
|
|
'timeColumn: "_time", startColumn: "_start", stopColumn: "_stop", createEmpty: true) ';
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $query, $expression->__toString() );
|
|
|
|
|
}
|
2022-08-31 15:32:13 +00:00
|
|
|
}
|