From ca1f6da9ce2ed06751576e9f5a28a2f360f8aaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bret=C3=A9ch=C3=A9?= Date: Tue, 17 Dec 2024 08:28:28 +0100 Subject: [PATCH] Add unit test. --- tests/Tests/ORM/Functional/ReadOnlyTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Tests/ORM/Functional/ReadOnlyTest.php index 4d06e107d07..44ffcac50d5 100644 --- a/tests/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Tests/ORM/Functional/ReadOnlyTest.php @@ -90,6 +90,26 @@ public function testReadOnlyQueryHint(): void self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); } + public function testNotReadOnlyQueryHint(): void + { + $user = new ReadOnlyEntity('beberlei', 1234); + + $this->_em->persist($user); + + $this->_em->flush(); + $this->_em->clear(); + + $dql = 'SELECT u FROM ' . ReadOnlyEntity::class . ' u WHERE u.id = ?1'; + + $query = $this->_em->createQuery($dql); + $query->setParameter(1, $user->id); + $query->setHint(Query::HINT_READ_ONLY, false); + + $user = $query->getSingleResult(); + + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + } + public function testNotReadOnlyIfObjectWasProxyBefore(): void { $user = new ReadOnlyEntity('beberlei', 1234);