Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test with actual lock modes #11465

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -99,7 +100,7 @@ public function testInvokeGetSelectSQL(): void
->with(
self::identicalTo(['name' => 'Foo']),
self::identicalTo([0]),
self::identicalTo(1),
self::identicalTo(LockMode::OPTIMISTIC),
self::identicalTo(2),
self::identicalTo(3),
self::identicalTo([4])
Expand All @@ -109,7 +110,7 @@ public function testInvokeGetSelectSQL(): void
self::assertSame('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL(
['name' => 'Foo'],
[0],
1,
LockMode::OPTIMISTIC,
2,
3,
[4]
Expand Down Expand Up @@ -228,13 +229,21 @@ public function testInvokeLoad(): void
self::identicalTo($entity),
self::identicalTo([0]),
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, [0], [1], 2, 3, [4]));
self::assertSame($entity, $persister->load(
['id' => 1],
$entity,
[0],
[1],
LockMode::PESSIMISTIC_READ,
3,
[4]
));
}

public function testInvokeLoadAll(): void
Expand Down Expand Up @@ -391,9 +400,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
Loading