Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GH-6394] Bugfix: IdentifierFlattener support for association non-obj…
…ect values. (#8384) * [GH-6394] Bugfix: IdentifierFlattener support for association non-object values * [GH-6394] Bugfix: BasicEntityPersister::update used wrong identifiers for version assignment. * Exclude MissingNativeTypeHint phpcs rule as 7.4 is not lowest version.
- Loading branch information
Showing
3 changed files
with
105 additions
and
1 deletion.
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
103 changes: 103 additions & 0 deletions
103
tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.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,103 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
class GH6394Test extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->_schemaTool->createSchema( | ||
[ | ||
$this->_em->getClassMetadata(A::class), | ||
$this->_em->getClassMetadata(B::class), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Test the the version of an entity can be fetched, when the id field and | ||
* the id column are different. | ||
* | ||
* @group 6393 | ||
*/ | ||
public function testFetchVersionValueForDifferentIdFieldAndColumn(): void | ||
{ | ||
$a = new A(1); | ||
$this->_em->persist($a); | ||
|
||
$b = new B($a, 'foo'); | ||
$this->_em->persist($b); | ||
$this->_em->flush(); | ||
|
||
self::assertSame(1, $b->version); | ||
|
||
$b->something = 'bar'; | ||
$this->_em->flush(); | ||
|
||
self::assertSame(2, $b->version); | ||
} | ||
} | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class A | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="integer") | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @Version | ||
* @Column(type="integer") | ||
* @var int | ||
*/ | ||
public $version; | ||
|
||
public function __construct(int $id) | ||
{ | ||
$this->id = $id; | ||
} | ||
} | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class B | ||
{ | ||
/** | ||
* @Id | ||
* @ManyToOne(targetEntity="A") | ||
* @JoinColumn(name="aid", referencedColumnName="id") | ||
* @var A | ||
*/ | ||
public $a; | ||
|
||
/** | ||
* @Column(type="string") | ||
* @var string | ||
*/ | ||
public $something; | ||
|
||
/** | ||
* @Version | ||
* @Column(type="integer") | ||
* @var int | ||
*/ | ||
public $version; | ||
|
||
public function __construct(A $a, string $something) | ||
{ | ||
$this->a = $a; | ||
$this->something = $something; | ||
} | ||
} |