Add Group, Limit, Map, Sort functions
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
1922f33c5c
commit
147b2d9017
11 changed files with 252 additions and 2 deletions
18
tests/Function/GroupFunctionTest.php
Normal file
18
tests/Function/GroupFunctionTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Function\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class GroupFunctionTest extends TestCase {
|
||||
|
||||
public function testSimpleGroup()
|
||||
{
|
||||
$expression = new Group(['foo', 'bar'], 'by');
|
||||
|
||||
$query = '|> group(columns: ["foo", "bar"], mode: "by") ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
|
||||
}
|
||||
18
tests/Function/LimitFunctionTest.php
Normal file
18
tests/Function/LimitFunctionTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Function\Limit;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class LimitFunctionTest extends TestCase {
|
||||
|
||||
public function testSimpleLimit()
|
||||
{
|
||||
$expression = new Limit(1);
|
||||
|
||||
$query = '|> limit(n:1) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
|
||||
}
|
||||
18
tests/Function/MapFunctionTest.php
Normal file
18
tests/Function/MapFunctionTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Function\Map;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class MapFunctionTest extends TestCase {
|
||||
|
||||
public function testSimpleMap()
|
||||
{
|
||||
$expression = new Map('r with name: r.user');
|
||||
|
||||
$query = '|> map(fn: (r) => ({ r with name: r.user })) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
|
||||
}
|
||||
18
tests/Function/SortFunctionTest.php
Normal file
18
tests/Function/SortFunctionTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Function\Sort;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SortFunctionTest extends TestCase {
|
||||
|
||||
public function testSimpleSort()
|
||||
{
|
||||
$expression = new Sort(['foo', 'bar'], true);
|
||||
|
||||
$query = '|> sort(columns: ["foo", "bar"], desc: true) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue