Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 557e1eb

Browse files
committed
Test IDENTITY
1 parent 7f2a331 commit 557e1eb

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

‎tests/Platform/Entity/PlatformEntity.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DateTimeInterface;
66
use Doctrine\ORM\Mapping as ORM;
7+
use Platform\Entity\PlatformRelatedEntity;
78

89
/**
910
* @ORM\Table(name="test")
@@ -23,6 +24,15 @@ class PlatformEntity
2324
#[ORM\Column(type: 'string', nullable: false)]
2425
public $id;
2526

27+
/**
28+
* @ORM\ManyToOne(targetEntity=PlatformRelatedEntity::class)
29+
* @ORM\JoinColumn(name="related_entity_id", referencedColumnName="id", nullable=false)
30+
* @var PlatformRelatedEntity
31+
*/
32+
#[ORM\ManyToOne(targetEntity: PlatformRelatedEntity::class)]
33+
#[ORM\JoinColumn(name: 'related_entity_id', referencedColumnName: 'id', nullable: false)]
34+
public $related_entity;
35+
2636
/**
2737
* @ORM\Column(type="string", name="col_string", nullable=false)
2838
* @var string
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace 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+
}

‎tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use PHPStan\Type\VerbosityLevel;
4747
use PHPUnit\Framework\Constraint\IsEqual;
4848
use PHPUnit\Framework\Constraint\IsIdentical;
49+
use Platform\Entity\PlatformRelatedEntity;
4950
use Psr\Log\LoggerInterface;
5051
use Throwable;
5152
use function class_exists;
@@ -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)

AltStyle によって変換されたページ (->オリジナル) /