Skip to content

Commit

Permalink
Merge branch '2.19.x' into 3.1.x
Browse files Browse the repository at this point in the history
* 2.19.x:
  Test with actual lock modes (#11465)
  Backport test for Query::setLockMode() (#11463)
  • Loading branch information
derrabus committed May 21, 2024
2 parents 1127042 + 552eae3 commit a90ee5c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tests/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister;
Expand Down Expand Up @@ -97,7 +98,7 @@ public function testInvokeGetSelectSQL(): void
->with(
self::identicalTo(['name' => 'Foo']),
self::identicalTo($associationMapping),
self::identicalTo(1),
self::identicalTo(LockMode::OPTIMISTIC),
self::identicalTo(2),
self::identicalTo(3),
self::identicalTo([4]),
Expand All @@ -107,7 +108,7 @@ public function testInvokeGetSelectSQL(): void
self::assertSame('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL(
['name' => 'Foo'],
$associationMapping,
1,
LockMode::OPTIMISTIC,
2,
3,
[4],
Expand Down Expand Up @@ -233,13 +234,21 @@ public function testInvokeLoad(): void
self::identicalTo($entity),
self::identicalTo($associationMapping),
self::identicalTo([1]),
self::identicalTo(2),
self::identicalTo(LockMode::PESSIMISTIC_READ),
self::identicalTo(3),
self::identicalTo([4]),
)
->willReturn($entity);

self::assertSame($entity, $persister->load(['id' => 1], $entity, $associationMapping, [1], 2, 3, [4]));
self::assertSame($entity, $persister->load(
['id' => 1],
$entity,
$associationMapping,
[1],
LockMode::PESSIMISTIC_READ,
3,
[4],
));
}

public function testInvokeLoadAll(): void
Expand Down Expand Up @@ -402,9 +411,9 @@ public function testInvokeLock(): void

$this->entityPersister->expects(self::once())
->method('lock')
->with(self::identicalTo($identifier), self::identicalTo(1));
->with(self::identicalTo($identifier), self::identicalTo(LockMode::OPTIMISTIC));

$persister->lock($identifier, 1);
$persister->lock($identifier, LockMode::OPTIMISTIC);
}

public function testInvokeExists(): void
Expand Down

0 comments on commit a90ee5c

Please sign in to comment.