Skip to content

Commit f02c1f0

Browse files
committed
Test IDENTITY
1 parent 7f2a331 commit f02c1f0

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

Diff for: tests/Platform/Entity/PlatformEntity.php

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ class PlatformEntity
2323
#[ORM\Column(type: 'string', nullable: false)]
2424
public $id;
2525

26+
/**
27+
* @ORM\ManyToOne(targetEntity=PlatformRelatedEntity::class)
28+
* @ORM\JoinColumn(name="related_entity_id", referencedColumnName="id", nullable=false)
29+
* @var PlatformRelatedEntity
30+
*/
31+
#[ORM\ManyToOne(targetEntity: PlatformRelatedEntity::class)]
32+
#[ORM\JoinColumn(name: 'related_entity_id', referencedColumnName: 'id', nullable: false)]
33+
public $related_entity;
34+
2635
/**
2736
* @ORM\Column(type="string", name="col_string", nullable=false)
2837
* @var string

Diff for: tests/Platform/Entity/PlatformRelatedEntity.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Platform\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Table(name="test_related")
9+
* @ORM\Entity
10+
*/
11+
#[ORM\Table(name: 'test_related')]
12+
#[ORM\Entity]
13+
class PlatformRelatedEntity
14+
{
15+
16+
/**
17+
* @ORM\Id
18+
* @ORM\Column(type="integer", nullable=false)
19+
* @var int
20+
*/
21+
#[ORM\Id]
22+
#[ORM\Column(type: 'integer', nullable: false)]
23+
public $id;
24+
25+
}

Diff for: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use PHPStan\Doctrine\Driver\DriverType;
2323
use PHPStan\Php\PhpVersion;
2424
use PHPStan\Platform\Entity\PlatformEntity;
25+
use PHPStan\Platform\Entity\PlatformRelatedEntity;
2526
use PHPStan\Testing\PHPStanTestCase;
2627
use PHPStan\Type\Accessory\AccessoryNumericStringType;
2728
use PHPStan\Type\BooleanType;
@@ -3509,7 +3510,21 @@ public static function provideCases(): iterable
35093510
'stringify' => self::STRINGIFY_DEFAULT,
35103511
];
35113512

3512-
// TODO test IDENTITY
3513+
yield 'IDENTITY(t.related_entity)' => [
3514+
'data' => self::dataDefault(),
3515+
'select' => 'SELECT IDENTITY(t.related_entity) FROM %s t',
3516+
'mysql' => self::int(),
3517+
'sqlite' => self::int(),
3518+
'pdo_pgsql' => self::int(),
3519+
'pgsql' => self::int(),
3520+
'mssql' => self::mixed(),
3521+
'mysqlResult' => 1,
3522+
'sqliteResult' => 1,
3523+
'pdoPgsqlResult' => 1,
3524+
'pgsqlResult' => 1,
3525+
'mssqlResult' => 1,
3526+
'stringify' => self::STRINGIFY_DEFAULT,
3527+
];
35133528
}
35143529

35153530
/**
@@ -3653,8 +3668,14 @@ private function getQuery(
36533668
$schemaTool->dropSchema($classes);
36543669
$schemaTool->createSchema($classes);
36553670

3671+
$relatedEntity = new PlatformRelatedEntity();
3672+
$relatedEntity->id = 1;
3673+
$entityManager->persist($relatedEntity);
3674+
36563675
foreach ($data as $rowData) {
36573676
$entity = new PlatformEntity();
3677+
$entity->related_entity = $relatedEntity;
3678+
36583679
foreach ($rowData as $column => $value) {
36593680
$entity->$column = $value; // @phpstan-ignore-line Intentionally dynamic
36603681
}

0 commit comments

Comments
 (0)