Improve FnType to add a body or block
Signed-off-by: David Arendsen <darendsen@gamepoint.com>
This commit is contained in:
parent
9e2bde4217
commit
ec73c70706
4 changed files with 56 additions and 26 deletions
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Functions;
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Functions\AggregateWindow;
|
||||
use Arendsen\FluxQueryBuilder\Type\FnType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class AggregateWindowFunctionTest extends TestCase
|
||||
|
|
@ -20,18 +21,22 @@ final class AggregateWindowFunctionTest extends TestCase
|
|||
|
||||
public function testAllParameters()
|
||||
{
|
||||
$expression = new AggregateWindow('20s', 'mean', [
|
||||
'period' => 'every',
|
||||
'offset' => '0s',
|
||||
'location' => 'location',
|
||||
'column' => '_value',
|
||||
'timeSrc' => '_stop',
|
||||
'timeDst' => '_time',
|
||||
'createEmpty' => false
|
||||
]);
|
||||
$expression = new AggregateWindow(
|
||||
'20s',
|
||||
FnType::params(['r'])->withBody('r._field == "test"'),
|
||||
[
|
||||
'period' => 'every',
|
||||
'offset' => '0s',
|
||||
'location' => 'location',
|
||||
'column' => '_value',
|
||||
'timeSrc' => '_stop',
|
||||
'timeDst' => '_time',
|
||||
'createEmpty' => false
|
||||
]
|
||||
);
|
||||
|
||||
$query = '|> aggregateWindow(every: 20s, period: every, offset: 0s, fn: mean, location: "location", ' .
|
||||
'column: "_value", timeSrc: "_stop", timeDst: "_time", createEmpty: false) ';
|
||||
$query = '|> aggregateWindow(every: 20s, period: every, offset: 0s, fn: (r) => r._field == "test",
|
||||
location: "location", ' . 'column: "_value", timeSrc: "_stop", timeDst: "_time", createEmpty: false) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue