Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'backport/fix/l2c-version' into 2.6
Backporting #7069
- Loading branch information
Showing
2 changed files
with
73 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
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,69 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
final class GH7067Test extends \Doctrine\Tests\OrmFunctionalTestCase | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->enableSecondLevelCache(); | ||
parent::setUp(); | ||
|
||
$this->setUpEntitySchema([GH7067Entity::class]); | ||
} | ||
|
||
/** | ||
* @group 7067 | ||
*/ | ||
public function testSLCWithVersion() : void | ||
{ | ||
$entity = new GH7067Entity(); | ||
$entity->lastUpdate = new \DateTime(); | ||
|
||
$this->_em->persist($entity); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
/** @var GH7067Entity $notCached */ | ||
$notCached = $this->_em->find(GH7067Entity::class, $entity->id); | ||
|
||
self::assertNotNull($notCached->version, 'Version already cached by persister above, it must be not null'); | ||
|
||
$notCached->lastUpdate = new \DateTime(); | ||
|
||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
} | ||
} | ||
|
||
/** | ||
* @Entity() | ||
* @Cache(usage="NONSTRICT_READ_WRITE") | ||
*/ | ||
class GH7067Entity | ||
{ | ||
/** | ||
* @Id | ||
* @GeneratedValue | ||
* @Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @Column(type="datetime") | ||
* | ||
* @var \DateTime | ||
*/ | ||
public $lastUpdate; | ||
|
||
/** | ||
* @Column(type="datetime") | ||
* @Version | ||
* | ||
* @var \DateTime | ||
*/ | ||
public $version; | ||
} |