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,97 +1,94 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace Tests\Type;
|
||||
|
||||
use DateTime;
|
||||
use Arendsen\FluxQueryBuilder\Type;
|
||||
use Arendsen\FluxQueryBuilder\Type\CustomType;
|
||||
use Arendsen\FluxQueryBuilder\Type\DurationType;
|
||||
use Arendsen\FluxQueryBuilder\Type\FnType;
|
||||
use Arendsen\FluxQueryBuilder\Type\MathType;
|
||||
use Arendsen\FluxQueryBuilder\Type\RecordType;
|
||||
use Hosterra\FluxBuilder\Type;
|
||||
use Hosterra\FluxBuilder\Type\CustomType;
|
||||
use Hosterra\FluxBuilder\Type\DurationType;
|
||||
use Hosterra\FluxBuilder\Type\FnType;
|
||||
use Hosterra\FluxBuilder\Type\MathType;
|
||||
use Hosterra\FluxBuilder\Type\RecordType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class FactoryTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getFluxStringProvider
|
||||
*/
|
||||
public function testGetFluxString($value, $expected)
|
||||
{
|
||||
$type = new Type($value);
|
||||
final class FactoryTypeTest extends TestCase {
|
||||
/**
|
||||
* @dataProvider getFluxStringProvider
|
||||
*/
|
||||
public function testGetFluxString( $value, $expected ) {
|
||||
$type = new Type( $value );
|
||||
|
||||
$this->assertEquals($expected, $type->__toString());
|
||||
}
|
||||
$this->assertEquals( $expected, $type->__toString() );
|
||||
}
|
||||
|
||||
public function getFluxStringProvider()
|
||||
{
|
||||
return [
|
||||
'DateTime' => [
|
||||
new DateTime('2022-08-15 23:09:00'),
|
||||
'time(v: 2022-08-15T23:09:00Z)',
|
||||
],
|
||||
'String' => [
|
||||
'value',
|
||||
'"value"',
|
||||
],
|
||||
'Integer' => [
|
||||
12345,
|
||||
'12345'
|
||||
],
|
||||
'Boolean True' => [
|
||||
true,
|
||||
'true'
|
||||
],
|
||||
'Boolean False' => [
|
||||
false,
|
||||
'false'
|
||||
],
|
||||
'Array' => [
|
||||
['hello', 'world'],
|
||||
'"hello", "world"'
|
||||
],
|
||||
'Dictionary' => [
|
||||
['hello' => 'world', 'foo' => 'bar'],
|
||||
'hello: "world", foo: "bar"'
|
||||
],
|
||||
'Array Multidimensional' => [
|
||||
['hello' => ['test', 'foo']],
|
||||
'hello: ["test", "foo"]'
|
||||
],
|
||||
'Array Multidimensional 2' => [
|
||||
['hello' => ['test' => 'bar', 'foo' => 'hi']],
|
||||
'hello: [test: "bar", foo: "hi"]'
|
||||
],
|
||||
'RecordType' => [
|
||||
new RecordType(['foo' => 'bar', 'nested' => ['hello' => 'world']]),
|
||||
'{foo: "bar", nested: {hello: "world"}}'
|
||||
],
|
||||
'DurationType' => [
|
||||
new DurationType('5h'),
|
||||
'5h',
|
||||
],
|
||||
'MathType' => [
|
||||
new MathType('r.count + 1'),
|
||||
'r.count + 1'
|
||||
],
|
||||
'CustomType' => [
|
||||
new CustomType('this can be anything'),
|
||||
'this can be anything'
|
||||
],
|
||||
'FnType with only content' => [
|
||||
FnType::params([])->withBlock('r with _value: r._value * r._value'),
|
||||
'() => { r with _value: r._value * r._value }'
|
||||
],
|
||||
'FnType with params and a body' => [
|
||||
FnType::params(['r'])->withBody('r with _value: r._value * r._value'),
|
||||
'(r) => r with _value: r._value * r._value'
|
||||
],
|
||||
'FnType with params and a block' => [
|
||||
FnType::params(['r', 'a'])->withBlock('return r with _value: r._value * r._value'),
|
||||
'(r, a) => { return r with _value: r._value * r._value }'
|
||||
],
|
||||
];
|
||||
}
|
||||
public function getFluxStringProvider() {
|
||||
return [
|
||||
'DateTime' => [
|
||||
new DateTime( '2022-08-15 23:09:00' ),
|
||||
'time(v: 2022-08-15T23:09:00Z)',
|
||||
],
|
||||
'String' => [
|
||||
'value',
|
||||
'"value"',
|
||||
],
|
||||
'Integer' => [
|
||||
12345,
|
||||
'12345'
|
||||
],
|
||||
'Boolean True' => [
|
||||
true,
|
||||
'true'
|
||||
],
|
||||
'Boolean False' => [
|
||||
false,
|
||||
'false'
|
||||
],
|
||||
'Array' => [
|
||||
[ 'hello', 'world' ],
|
||||
'"hello", "world"'
|
||||
],
|
||||
'Dictionary' => [
|
||||
[ 'hello' => 'world', 'foo' => 'bar' ],
|
||||
'hello: "world", foo: "bar"'
|
||||
],
|
||||
'Array Multidimensional' => [
|
||||
[ 'hello' => [ 'test', 'foo' ] ],
|
||||
'hello: ["test", "foo"]'
|
||||
],
|
||||
'Array Multidimensional 2' => [
|
||||
[ 'hello' => [ 'test' => 'bar', 'foo' => 'hi' ] ],
|
||||
'hello: [test: "bar", foo: "hi"]'
|
||||
],
|
||||
'RecordType' => [
|
||||
new RecordType( [ 'foo' => 'bar', 'nested' => [ 'hello' => 'world' ] ] ),
|
||||
'{foo: "bar", nested: {hello: "world"}}'
|
||||
],
|
||||
'DurationType' => [
|
||||
new DurationType( '5h' ),
|
||||
'5h',
|
||||
],
|
||||
'MathType' => [
|
||||
new MathType( 'r.count + 1' ),
|
||||
'r.count + 1'
|
||||
],
|
||||
'CustomType' => [
|
||||
new CustomType( 'this can be anything' ),
|
||||
'this can be anything'
|
||||
],
|
||||
'FnType with only content' => [
|
||||
FnType::params( [] )->withBlock( 'r with _value: r._value * r._value' ),
|
||||
'() => { r with _value: r._value * r._value }'
|
||||
],
|
||||
'FnType with params and a body' => [
|
||||
FnType::params( [ 'r' ] )->withBody( 'r with _value: r._value * r._value' ),
|
||||
'(r) => r with _value: r._value * r._value'
|
||||
],
|
||||
'FnType with params and a block' => [
|
||||
FnType::params( [ 'r', 'a' ] )->withBlock( 'return r with _value: r._value * r._value' ),
|
||||
'(r, a) => { return r with _value: r._value * r._value }'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue