-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JSON mapping linting against subset of builtin types
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket\GH11072; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class GH11072EntityAdvanced extends GH11072EntityBasic | ||
{ | ||
/** @Column(type="json") */ | ||
public mixed $anything; | ||
|
||
/** @Column(type="json") */ | ||
public true $alwaysTrue = true; | ||
|
||
/** @Column(type="json") */ | ||
public false $alwaysFalse = false; | ||
|
||
/** @Column(type="json") */ | ||
public null $alwaysNull = null; | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket\GH11072; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\GeneratedValue; | ||
use Doctrine\ORM\Mapping\Id; | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class GH11072EntityBasic | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="integer") | ||
* @GeneratedValue | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** @Column(type="json") */ | ||
public string $jsonString = 'test'; | ||
|
||
/** @Column(type="json") */ | ||
public int $age = 99; | ||
|
||
/** @Column(type="json") */ | ||
public float $score = 0.0; | ||
|
||
/** @Column(type="json", nullable=true) */ | ||
public ?bool $trinary = null; | ||
|
||
/** @Column(type="json") */ | ||
public array $metadata = []; | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket\GH11072; | ||
|
||
use Doctrine\ORM\Tools\SchemaValidator; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
/** | ||
* @requires PHP >= 7.4 | ||
*/ | ||
final class GH11072Test extends OrmFunctionalTestCase | ||
{ | ||
/** @var SchemaValidator */ | ||
private $validator; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->_em = $this->getTestEntityManager(); | ||
$this->validator = new SchemaValidator($this->_em); | ||
} | ||
|
||
public function testAcceptsSubsetOfBuiltinTypesWithoutErrors(): void | ||
{ | ||
$class = $this->_em->getClassMetadata(GH11072EntityBasic::class); | ||
$ce = $this->validator->validateClass($class); | ||
|
||
self::assertSame([], $ce); | ||
} | ||
|
||
/** | ||
* @requires PHP >= 8.2 | ||
*/ | ||
public function testAcceptsAdvancedSubsetOfBuiltinTypesWithoutErrors(): void | ||
{ | ||
$class = $this->_em->getClassMetadata(GH11072EntityAdvanced::class); | ||
$ce = $this->validator->validateClass($class); | ||
|
||
self::assertSame([], $ce); | ||
} | ||
} |