New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inherited embeddables and nesting after AnnotationDriver change #8006 #8036
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f3402cd
Add test case
malarzm 39dfce6
Treat parent embeddables as mapped superclasses
malarzm 961b20b
[GH-8031] Bugfix: Get working again on nested embeddables in inherite…
beberlei 5f5b3a5
Housekeeping: CS
beberlei a8cd2d4
Update note on limitations
malarzm 27575b8
[GH-8031] Verify assocations still do not work with Embeddables.
beberlei e2ead2e
Housekeeping: CS
beberlei File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
163 changes: 163 additions & 0 deletions
163
tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.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,163 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
class GH8031Test extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->setUpEntitySchema([ | ||
GH8031Invoice::class, | ||
]); | ||
} | ||
|
||
public function testEntityIsFetched() | ||
{ | ||
$entity = new GH8031Invoice(new GH8031InvoiceCode(1, 2020, new GH8031Nested(10))); | ||
$this->_em->persist($entity); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
/** @var GH8031Invoice $fetched */ | ||
$fetched = $this->_em->find(GH8031Invoice::class, $entity->getId()); | ||
$this->assertInstanceOf(GH8031Invoice::class, $fetched); | ||
$this->assertSame(1, $fetched->getCode()->getNumber()); | ||
$this->assertSame(2020, $fetched->getCode()->getYear()); | ||
|
||
$this->_em->clear(); | ||
$this->assertCount( | ||
1, | ||
$this->_em->getRepository(GH8031Invoice::class)->findBy([], ['code.number' => 'ASC']) | ||
); | ||
} | ||
|
||
public function testEmbeddableWithAssociationNotAllowed() | ||
{ | ||
$cm = $this->_em->getClassMetadata(GH8031EmbeddableWithAssociation::class); | ||
|
||
$this->assertArrayHasKey('invoice', $cm->associationMappings); | ||
|
||
$cm = $this->_em->getClassMetadata(GH8031Invoice::class); | ||
|
||
$this->assertCount(0, $cm->associationMappings); | ||
} | ||
} | ||
|
||
/** | ||
* @Embeddable | ||
*/ | ||
class GH8031EmbeddableWithAssociation | ||
{ | ||
/** @ManyToOne(targetEntity=GH8031Invoice::class) */ | ||
public $invoice; | ||
} | ||
|
||
/** | ||
* @Embeddable | ||
*/ | ||
class GH8031Nested | ||
{ | ||
/** | ||
* @Column(type="integer", name="number", length=6) | ||
* @var int | ||
*/ | ||
protected $number; | ||
|
||
public function __construct(int $number) | ||
{ | ||
$this->number = $number; | ||
} | ||
|
||
public function getNumber() : int | ||
{ | ||
return $this->number; | ||
} | ||
} | ||
|
||
/** | ||
* @Embeddable | ||
*/ | ||
class GH8031InvoiceCode extends GH8031AbstractYearSequenceValue | ||
{ | ||
} | ||
|
||
/** | ||
* @Embeddable | ||
*/ | ||
abstract class GH8031AbstractYearSequenceValue | ||
{ | ||
/** | ||
* @Column(type="integer", name="number", length=6) | ||
* @var int | ||
*/ | ||
protected $number; | ||
|
||
/** | ||
* @Column(type="smallint", name="year", length=4) | ||
* @var int | ||
*/ | ||
protected $year; | ||
|
||
/** @Embedded(class=GH8031Nested::class) */ | ||
protected $nested; | ||
|
||
public function __construct(int $number, int $year, GH8031Nested $nested) | ||
{ | ||
$this->number = $number; | ||
$this->year = $year; | ||
$this->nested = $nested; | ||
} | ||
|
||
public function getNumber() : int | ||
{ | ||
return $this->number; | ||
} | ||
|
||
public function getYear() : int | ||
{ | ||
return $this->year; | ||
} | ||
} | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class GH8031Invoice | ||
{ | ||
/** | ||
* @Id | ||
* @GeneratedValue | ||
* @Column(type="integer") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @Embedded(class=GH8031InvoiceCode::class) | ||
* @var GH8031InvoiceCode | ||
*/ | ||
private $code; | ||
|
||
/** @Embedded(class=GH8031EmbeddableWithAssociation::class) */ | ||
private $embeddedAssoc; | ||
|
||
public function __construct(GH8031InvoiceCode $code) | ||
{ | ||
$this->code = $code; | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getCode() : GH8031InvoiceCode | ||
{ | ||
return $this->code; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the time has come to move the whole expression of this if condition into a function :-)