File tree Expand file tree Collapse file tree 5 files changed +184
-0
lines changed
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions Expand file tree Collapse file tree 5 files changed +184
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Integration \MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
6+
7+ use MartinGeorgiev \Doctrine \ORM \Query \AST \Functions \Daterange ;
8+
9+ class DaterangeTest extends DateTestCase
10+ {
11+ protected function getStringFunctions (): array
12+ {
13+ return [
14+ 'DATERANGE ' => Daterange::class,
15+ ];
16+ }
17+
18+ public function test_daterange (): void
19+ {
20+ $ dql = "SELECT DATERANGE(t.date1, t.date2) as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsDates t WHERE t.id = 1 " ;
21+ $ result = $ this ->executeDqlQuery ($ dql );
22+ $ this ->assertIsArray ($ result );
23+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
24+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
25+ $ this ->assertSame ('[2023-06-15,2023-06-16) ' , $ actual );
26+ }
27+
28+ public function test_daterange_with_bounds (): void
29+ {
30+ $ dql = "SELECT DATERANGE(t.date1, t.date2, '[)') as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsDates t WHERE t.id = 1 " ;
31+ $ result = $ this ->executeDqlQuery ($ dql );
32+ $ this ->assertIsArray ($ result );
33+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
34+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
35+ $ this ->assertSame ('[2023-06-15,2023-06-16) ' , $ actual );
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Integration \MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
6+
7+ use MartinGeorgiev \Doctrine \ORM \Query \AST \Functions \Int4range ;
8+
9+ class Int4rangeTest extends JsonTestCase
10+ {
11+ protected function getStringFunctions (): array
12+ {
13+ return [
14+ 'INT4RANGE ' => Int4range::class,
15+ ];
16+ }
17+
18+ public function test_int4range (): void
19+ {
20+ $ dql = "SELECT INT4RANGE(:start, :end) as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsJsons t WHERE t.id = 1 " ;
21+ $ result = $ this ->executeDqlQuery ($ dql , [
22+ 'start ' => 10 ,
23+ 'end ' => 20 ,
24+ ]);
25+ $ this ->assertIsArray ($ result );
26+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
27+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
28+ $ this ->assertSame ('[10,20) ' , $ actual );
29+ }
30+
31+ public function test_int4range_with_bounds (): void
32+ {
33+ $ dql = "SELECT INT4RANGE(:start, :end, '[)') as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsJsons t WHERE t.id = 1 " ;
34+ $ result = $ this ->executeDqlQuery ($ dql , [
35+ 'start ' => 10 ,
36+ 'end ' => 20 ,
37+ ]);
38+ $ this ->assertIsArray ($ result );
39+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
40+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
41+ $ this ->assertSame ('[10,20) ' , $ actual );
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Integration \MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
6+
7+ use MartinGeorgiev \Doctrine \ORM \Query \AST \Functions \Int8range ;
8+
9+ class Int8rangeTest extends JsonTestCase
10+ {
11+ protected function getStringFunctions (): array
12+ {
13+ return [
14+ 'INT8RANGE ' => Int8range::class,
15+ ];
16+ }
17+
18+ public function test_int8range (): void
19+ {
20+ $ dql = "SELECT INT8RANGE(:start, :end) as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsJsons t WHERE t.id = 1 " ;
21+ $ result = $ this ->executeDqlQuery ($ dql , [
22+ 'start ' => 100 ,
23+ 'end ' => 200 ,
24+ ]);
25+ $ this ->assertIsArray ($ result );
26+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
27+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
28+ $ this ->assertSame ('[100,200) ' , $ actual );
29+ }
30+
31+ public function test_int8range_with_bounds (): void
32+ {
33+ $ dql = "SELECT INT8RANGE(:start, :end, '[)') as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsJsons t WHERE t.id = 1 " ;
34+ $ result = $ this ->executeDqlQuery ($ dql , [
35+ 'start ' => 1000 ,
36+ 'end ' => 2000 ,
37+ ]);
38+ $ this ->assertIsArray ($ result );
39+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
40+ $ actual = (string )($ result [0 ]['result ' ] ?? '' );
41+ $ this ->assertSame ('[1000,2000) ' , $ actual );
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Integration \MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
6+
7+ use MartinGeorgiev \Doctrine \ORM \Query \AST \Functions \Tsrange ;
8+
9+ class TsrangeTest extends DateTestCase
10+ {
11+ protected function getStringFunctions (): array
12+ {
13+ return [
14+ 'TSRANGE ' => Tsrange::class,
15+ ];
16+ }
17+
18+ public function test_tsrange (): void
19+ {
20+ $ dql = 'SELECT TSRANGE(t.datetime1, t.datetime2) as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsDates t WHERE t.id = 1 ' ;
21+ $ result = $ this ->executeDqlQuery ($ dql );
22+ $ this ->assertIsArray ($ result );
23+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
24+ $ this ->assertSame ('["2023-06-15 10:30:00","2023-06-16 11:45:00") ' , (string ) $ result [0 ]['result ' ]);
25+ }
26+
27+ public function test_tsrange_with_bounds (): void
28+ {
29+ $ dql = "SELECT TSRANGE(t.datetime1, t.datetime2, '[)') as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsDates t WHERE t.id = 1 " ;
30+ $ result = $ this ->executeDqlQuery ($ dql );
31+ $ this ->assertIsArray ($ result );
32+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
33+ $ this ->assertSame ('["2023-06-15 10:30:00","2023-06-16 11:45:00") ' , (string ) $ result [0 ]['result ' ]);
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Integration \MartinGeorgiev \Doctrine \ORM \Query \AST \Functions ;
6+
7+ use MartinGeorgiev \Doctrine \ORM \Query \AST \Functions \Tstzrange ;
8+
9+ class TstzrangeTest extends JsonTestCase
10+ {
11+ protected function getStringFunctions (): array
12+ {
13+ return [
14+ 'TSTZRANGE ' => Tstzrange::class,
15+ ];
16+ }
17+
18+ public function test_tstzrange (): void
19+ {
20+ $ dql = "SELECT TSTZRANGE('2024-01-01 00:00:00+00', '2024-12-31 23:59:59+00') as result FROM Fixtures \\MartinGeorgiev \\Doctrine \\Entity \\ContainsJsons t WHERE t.id = 1 " ;
21+ $ result = $ this ->executeDqlQuery ($ dql );
22+ $ this ->assertIsArray ($ result );
23+ $ this ->assertNotEmpty ($ result [0 ]['result ' ]);
24+ $ this ->assertSame ('["2024-01-01 00:00:00+00","2024-12-31 23:59:59+00") ' , (string ) $ result [0 ]['result ' ]);
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments