Marks fork as 2.0.0.
This commit is contained in:
parent
d93a6b5c09
commit
8d8de4a2b0
81 changed files with 1921 additions and 3954 deletions
|
|
@ -1,47 +1,43 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace Tests\Functions;
|
||||
|
||||
use Arendsen\FluxQueryBuilder\Functions\Map;
|
||||
use Arendsen\FluxQueryBuilder\Expression\Map as MapExpression;
|
||||
use Arendsen\FluxQueryBuilder\Expression\Selection as SelectionExpression;
|
||||
use Hosterra\FluxBuilder\Functions\Map;
|
||||
use Hosterra\FluxBuilder\Expression\Map as MapExpression;
|
||||
use Hosterra\FluxBuilder\Expression\Selection as SelectionExpression;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class MapFunctionTest extends TestCase
|
||||
{
|
||||
public function testSimpleMap()
|
||||
{
|
||||
$expression = new Map('r with name: r.user');
|
||||
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 })) ';
|
||||
$query = '|> map(fn: (r) => ({ r with name: r.user })) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
$this->assertEquals( $query, $expression->__toString() );
|
||||
}
|
||||
|
||||
public function testWithMapObject()
|
||||
{
|
||||
$expression = new Map(MapExpression::with('name', 'r.user'));
|
||||
public function testWithMapObject() {
|
||||
$expression = new Map( MapExpression::with( 'name', 'r.user' ) );
|
||||
|
||||
$query = '|> map(fn: (r) => ({ r with name: r.user })) ';
|
||||
$query = '|> map(fn: (r) => ({ r with name: r.user })) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
$this->assertEquals( $query, $expression->__toString() );
|
||||
}
|
||||
|
||||
public function testRecordMapObject()
|
||||
{
|
||||
$expression = new Map(MapExpression::columns([
|
||||
'time' => 'r._time',
|
||||
'source' => 'r.tag',
|
||||
'alert' => SelectionExpression::if('r._value > 10')->then(true)->else(false)->__toString(),
|
||||
'test' => SelectionExpression::if('r._value > 10')->then('yes')->else('no')->__toString()
|
||||
])->__toString());
|
||||
public function testRecordMapObject() {
|
||||
$expression = new Map( MapExpression::columns( [
|
||||
'time' => 'r._time',
|
||||
'source' => 'r.tag',
|
||||
'alert' => SelectionExpression::if( 'r._value > 10' )->then( true )->else( false )->__toString(),
|
||||
'test' => SelectionExpression::if( 'r._value > 10' )->then( 'yes' )->else( 'no' )->__toString()
|
||||
] )->__toString() );
|
||||
|
||||
$query = '|> map(fn: (r) => ({ {time: r._time, source: r.tag, ' .
|
||||
'alert: if r._value > 10 then true else false, ' .
|
||||
'test: if r._value > 10 then "yes" else "no"} })) ';
|
||||
$query = '|> map(fn: (r) => ({ {time: r._time, source: r.tag, ' .
|
||||
'alert: if r._value > 10 then true else false, ' .
|
||||
'test: if r._value > 10 then "yes" else "no"} })) ';
|
||||
|
||||
$this->assertEquals($query, $expression->__toString());
|
||||
}
|
||||
$this->assertEquals( $query, $expression->__toString() );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue