Skip to content

Commit

Permalink
Add unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbreteche committed Dec 17, 2024
1 parent 62a66ef commit ca1f6da
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Tests/ORM/Functional/ReadOnlyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ca1f6da

Please sign in to comment.