Skip to content

Commit 1d4ab0a

Browse files
committed
EntityColumnRule - test Id without GeneratedValue
1 parent e317317 commit 1d4ab0a

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ public function generatedIdsProvider(): Iterator
176176
yield 'nullable property' => [__DIR__ . '/data/GeneratedIdEntity3.php', []];
177177
yield 'nullable both' => [__DIR__ . '/data/GeneratedIdEntity4.php', []];
178178
yield 'composite' => [__DIR__ . '/data/CompositePrimaryKeyEntity1.php', []];
179+
yield 'no generated value 1' => [__DIR__ . '/data/GeneratedIdEntity5.php', []];
180+
yield 'no generated value 2' => [__DIR__ . '/data/GeneratedIdEntity6.php', [
181+
[
182+
'Property PHPStan\Rules\Doctrine\ORM\GeneratedIdEntity6::$id type mapping mismatch: property can contain int|null but database expects int.',
183+
18,
184+
],
185+
]];
179186
}
180187

181188
public function testCustomType(): void
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Doctrine\ORM;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity()
9+
*/
10+
class GeneratedIdEntity5
11+
{
12+
13+
/**
14+
* @ORM\Id()
15+
* @ORM\Column(type="integer", nullable=false)
16+
* @var int
17+
*/
18+
private $id;
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Doctrine\ORM;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity()
9+
*/
10+
class GeneratedIdEntity6
11+
{
12+
13+
/**
14+
* @ORM\Id()
15+
* @ORM\Column(type="integer", nullable=false)
16+
* @var int|null
17+
*/
18+
private $id;
19+
20+
}

0 commit comments

Comments
 (0)