Skip to content

Commit 25e200b

Browse files
janedbalondrejmirtes
authored andcommitted
Add unary minus test
1 parent b860565 commit 25e200b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static function setUpBeforeClass(): void
8282

8383
$dataOne = [
8484
'intColumn' => [1, 2],
85+
'floatColumn' => [0.1, 2.0],
8586
'stringColumn' => ['A', 'B'],
8687
'stringNullColumn' => ['A', null],
8788
];
@@ -108,10 +109,11 @@ public static function setUpBeforeClass(): void
108109
$id = 1;
109110

110111
foreach (self::combinations($dataOne) as $combination) {
111-
[$intColumn, $stringColumn, $stringNullColumn] = $combination;
112+
[$intColumn, $floatColumn, $stringColumn, $stringNullColumn] = $combination;
112113
$one = new One();
113114
$one->id = (string) $id++;
114115
$one->intColumn = $intColumn;
116+
$one->floatColumn = $floatColumn;
115117
$one->stringColumn = $stringColumn;
116118
$one->stringNullColumn = $stringNullColumn;
117119
$embedded = new Embedded();
@@ -1614,6 +1616,20 @@ public function getTestData(): iterable
16141616
FROM QueryResult\Entities\One o
16151617
',
16161618
];
1619+
1620+
yield 'unary minus' => [
1621+
$this->constantArray([
1622+
[new ConstantStringType('minusInt'), $this->numericStringOrInt()], // should be nullable
1623+
[new ConstantStringType('minusFloat'), TypeCombinator::union(new FloatType(), $this->numericStringOrInt())], // should be nullable && should not include int
1624+
[new ConstantStringType('minusIntRange'), TypeCombinator::union(IntegerRangeType::fromInterval(null, 0), $this->numericString())],
1625+
]),
1626+
'
1627+
SELECT -o.intColumn as minusInt,
1628+
-o.floatColumn as minusFloat,
1629+
-COUNT(o.intColumn) as minusIntRange
1630+
FROM QueryResult\Entities\One o
1631+
',
1632+
];
16171633
}
16181634

16191635
/**

Diff for: tests/Type/Doctrine/data/QueryResult/Entities/One.php

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class One
3131
*/
3232
public $intColumn;
3333

34+
/**
35+
* @Column(type="float")
36+
*
37+
* @var float
38+
*/
39+
public $floatColumn;
40+
3441
/**
3542
* @Column(type="string")
3643
*

0 commit comments

Comments
 (0)