diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 1b56794a842..f2ca0b2cc70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -32,8 +32,10 @@ protected function setUp(): void /** * @group DDC-178 * @group locking + * @testWith [false] + * [true] */ - public function testLockVersionedEntity(): void + public function testLockVersionedEntity(bool $useStringVersion): void { $article = new CmsArticle(); $article->text = 'my article'; @@ -42,7 +44,15 @@ public function testLockVersionedEntity(): void $this->_em->persist($article); $this->_em->flush(); - $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version); + $lockVersion = $article->version; + if ($useStringVersion) { + // NOTE: Officially, the lock method (and callers) do not accept a string argument. Calling code should + // cast the version to (int) as per the docs. However, this is not currently enforced. This may change in + // a future release. + $lockVersion = (string) $lockVersion; + } + + $this->_em->lock($article, LockMode::OPTIMISTIC, $lockVersion); $this->addToAssertionCount(1); } @@ -50,8 +60,10 @@ public function testLockVersionedEntity(): void /** * @group DDC-178 * @group locking + * @testWith [false] + * [true] */ - public function testLockVersionedEntityMismatchThrowsException(): void + public function testLockVersionedEntityMismatchThrowsException(bool $useStringVersion): void { $article = new CmsArticle(); $article->text = 'my article'; @@ -61,8 +73,12 @@ public function testLockVersionedEntityMismatchThrowsException(): void $this->_em->flush(); $this->expectException(OptimisticLockException::class); + $lockVersion = $article->version + 1; + if ($useStringVersion) { + $lockVersion = (string) $lockVersion; + } - $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); + $this->_em->lock($article, LockMode::OPTIMISTIC, $lockVersion); } /**