-
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.
Failing test: Illegal to-many association on MappedSuperclass not rej…
…ected
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
tests/Doctrine/Tests/ORM/Functional/Ticket/GH10449Test.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,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\ORM\Mapping\MappingException; | ||
use Doctrine\Tests\OrmTestCase; | ||
|
||
class GH10449Test extends OrmTestCase | ||
{ | ||
public function testToManyAssociationOnMappedSuperclassShallBeRejected(): void | ||
{ | ||
$em = $this->getTestEntityManager(); | ||
$classes = [GH10449MappedSuperclass::class, GH10449Entity::class, GH10449ToManyAssociationTarget::class]; | ||
|
||
$this->expectException(MappingException::class); | ||
$this->expectExceptionMessageMatches('/illegal to put an inverse side one-to-many or many-to-many association on mapped superclass/'); | ||
|
||
foreach ($classes as $class) { | ||
$em->getClassMetadata($class); | ||
} | ||
} | ||
|
||
/** | ||
* Override for BC with PHPUnit <8 | ||
*/ | ||
public function expectExceptionMessageMatches(string $regularExpression): void | ||
{ | ||
if (method_exists(get_parent_class($this), 'expectExceptionMessageMatches')) { | ||
parent::expectExceptionMessageMatches($regularExpression); | ||
} else { | ||
parent::expectExceptionMessageRegExp($regularExpression); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10449ToManyAssociationTarget | ||
{ | ||
/** | ||
* @ORM\Column(type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="GH10449MappedSuperclass", inversedBy="targets") | ||
* | ||
* @var GH10449MappedSuperclass | ||
*/ | ||
public $base; | ||
} | ||
|
||
/** | ||
* @ORM\MappedSuperclass | ||
*/ | ||
class GH10449MappedSuperclass | ||
{ | ||
/** | ||
* @ORM\Column(type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ORM\OneToMany(targetEntity="GH10449ToManyAssociationTarget", mappedBy="base") | ||
* | ||
* @var Collection | ||
*/ | ||
public $targets; | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10449Entity extends GH10449MappedSuperclass | ||
{ | ||
} |