Skip to content

Commit a59b33b

Browse files
committed
Test new descriptors
1 parent 7c3d1a1 commit a59b33b

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use PHPStan\Type\Type;
3737
use PHPStan\Type\TypeCombinator;
3838
use PHPStan\Type\VerbosityLevel;
39+
use QueryResult\Entities\Dbal4Entity;
3940
use QueryResult\Entities\Embedded;
4041
use QueryResult\Entities\JoinedChild;
4142
use QueryResult\Entities\Many;
@@ -187,6 +188,15 @@ public static function setUpBeforeClass(): void
187188
$em->persist($entityWithEnum);
188189
}
189190

191+
if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/dbal', '>=4.2')) {
192+
assert(class_exists(Dbal4Entity::class));
193+
194+
$dbal4Entity = new Dbal4Entity();
195+
$dbal4Entity->enum = 'a';
196+
$dbal4Entity->smallfloat = 1.1;
197+
$em->persist($dbal4Entity);
198+
}
199+
190200
$em->flush();
191201
}
192202

@@ -1532,6 +1542,25 @@ private function yieldConditionalDataset(): iterable
15321542
];
15331543
}
15341544

1545+
if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/dbal', '>=4.2')) {
1546+
yield 'enum and smallfloat' => [
1547+
$this->constantArray([
1548+
[
1549+
new ConstantStringType('enum'),
1550+
new StringType(),
1551+
],
1552+
[
1553+
new ConstantStringType('smallfloat'),
1554+
new FloatType(),
1555+
],
1556+
]),
1557+
'
1558+
SELECT e.enum, e.smallfloat
1559+
FROM QueryResult\Entities\Dbal4Entity e
1560+
',
1561+
];
1562+
}
1563+
15351564
$ormVersion = InstalledVersions::getVersion('doctrine/orm');
15361565
$hasOrm3 = $ormVersion !== null && strpos($ormVersion, '3.') === 0;
15371566

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace QueryResult\Entities;
4+
5+
use Doctrine\ORM\Mapping\Column;
6+
use Doctrine\ORM\Mapping\Entity;
7+
use Doctrine\ORM\Mapping\GeneratedValue;
8+
use Doctrine\ORM\Mapping\Id;
9+
10+
/**
11+
* @Entity
12+
*/
13+
class Dbal4Entity
14+
{
15+
16+
/**
17+
* @Column(type="integer")
18+
* @GeneratedValue(strategy="AUTO")
19+
* @Id()
20+
*
21+
* @var int
22+
*/
23+
public $id;
24+
25+
/**
26+
* @Column(type="enum", options={"values"={"a", "b", "c"}})
27+
* @var string
28+
*/
29+
public $enum; // dbal 4.2+
30+
31+
/**
32+
* @Column(type="smallfloat")
33+
* @var float
34+
*/
35+
public $smallfloat; // dbal 4.1+
36+
}

0 commit comments

Comments
 (0)