Skip to content

Commit

Permalink
EntityColumnRule - test Id without GeneratedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 19, 2021
1 parent e317317 commit 1d4ab0a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ public function generatedIdsProvider(): Iterator
yield 'nullable property' => [__DIR__ . '/data/GeneratedIdEntity3.php', []];
yield 'nullable both' => [__DIR__ . '/data/GeneratedIdEntity4.php', []];
yield 'composite' => [__DIR__ . '/data/CompositePrimaryKeyEntity1.php', []];
yield 'no generated value 1' => [__DIR__ . '/data/GeneratedIdEntity5.php', []];
yield 'no generated value 2' => [__DIR__ . '/data/GeneratedIdEntity6.php', [
[
'Property PHPStan\Rules\Doctrine\ORM\GeneratedIdEntity6::$id type mapping mismatch: property can contain int|null but database expects int.',
18,
],
]];
}

public function testCustomType(): void
Expand Down
20 changes: 20 additions & 0 deletions tests/Rules/Doctrine/ORM/data/GeneratedIdEntity5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

namespace PHPStan\Rules\Doctrine\ORM;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
*/
class GeneratedIdEntity5
{

/**
* @ORM\Id()
* @ORM\Column(type="integer", nullable=false)
* @var int
*/
private $id;

}
20 changes: 20 additions & 0 deletions tests/Rules/Doctrine/ORM/data/GeneratedIdEntity6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

namespace PHPStan\Rules\Doctrine\ORM;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
*/
class GeneratedIdEntity6
{

/**
* @ORM\Id()
* @ORM\Column(type="integer", nullable=false)
* @var int|null
*/
private $id;

}

0 comments on commit 1d4ab0a

Please # to comment.