forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request doctrine#9541 from greg0ire/improve-templating
- Loading branch information
Showing
8 changed files
with
131 additions
and
47 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
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
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
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
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
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
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
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Mapping; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\ORM\Mapping\Driver\AttributeReader; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionProperty; | ||
|
||
/** | ||
* @requires PHP 8.0 | ||
*/ | ||
class AttributeReaderTest extends TestCase | ||
{ | ||
public function testItThrowsWhenGettingRepeatableAnnotationWithTheWrongMethod(): void | ||
{ | ||
$reader = new AttributeReader(); | ||
$property = new ReflectionProperty(TestEntity::class, 'id'); | ||
$this->expectException(LogicException::class); | ||
$this->expectExceptionMessage( | ||
'The attribute "Doctrine\ORM\Mapping\Index" is repeatable. Call getPropertyAnnotationCollection() instead.' | ||
); | ||
$reader->getPropertyAnnotation($property, ORM\Index::class); | ||
} | ||
|
||
public function testItThrowsWhenGettingNonRepeatableAnnotationWithTheWrongMethod(): void | ||
{ | ||
$reader = new AttributeReader(); | ||
$property = new ReflectionProperty(TestEntity::class, 'id'); | ||
$this->expectException(LogicException::class); | ||
$this->expectExceptionMessage( | ||
'The attribute "Doctrine\ORM\Mapping\Id" is not repeatable. Call getPropertyAnnotation() instead.' | ||
); | ||
$reader->getPropertyAnnotationCollection($property, ORM\Id::class); | ||
} | ||
} | ||
|
||
#[ORM\Entity] | ||
#[ORM\Index(name: 'bar', columns: ['id'])] | ||
class TestEntity | ||
{ | ||
#[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] | ||
/** @var int */ | ||
public $id; | ||
} |