55namespace Doctrine \Tests \ORM \Functional \Locking ;
66
77use Doctrine \DBAL \LockMode ;
8+ use Doctrine \DBAL \Platforms \SQLitePlatform ;
89use Doctrine \ORM \OptimisticLockException ;
910use Doctrine \ORM \Query ;
1011use Doctrine \ORM \TransactionRequiredException ;
@@ -168,9 +169,7 @@ public function testRefreshWithLockPessimisticWriteNoTransactionThrowsException(
168169 */
169170 public function testLockPessimisticWrite (): void
170171 {
171- $ writeLockSql = $ this ->_em ->getConnection ()->getDatabasePlatform ()->getWriteLockSQL ();
172-
173- if (! $ writeLockSql ) {
172+ if ($ this ->_em ->getConnection ()->getDatabasePlatform () instanceof SQLitePlatform) {
174173 self ::markTestSkipped ('Database Driver has no Write Lock support. ' );
175174 }
176175
@@ -195,17 +194,15 @@ public function testLockPessimisticWrite(): void
195194 $ lastLoggedQuery = $ this ->getLastLoggedQuery (1 )['sql ' ];
196195 }
197196
198- self ::assertStringContainsString ($ writeLockSql , $ lastLoggedQuery );
197+ self ::assertStringContainsString (' FOR UPDATE ' , $ lastLoggedQuery );
199198 }
200199
201200 /**
202201 * @group locking
203202 */
204203 public function testRefreshWithLockPessimisticWrite (): void
205204 {
206- $ writeLockSql = $ this ->_em ->getConnection ()->getDatabasePlatform ()->getWriteLockSQL ();
207-
208- if (! $ writeLockSql ) {
205+ if ($ this ->_em ->getConnection ()->getDatabasePlatform () instanceof SQLitePlatform) {
209206 self ::markTestSkipped ('Database Driver has no Write Lock support. ' );
210207 }
211208
@@ -230,15 +227,13 @@ public function testRefreshWithLockPessimisticWrite(): void
230227 $ lastLoggedQuery = $ this ->getLastLoggedQuery (1 )['sql ' ];
231228 }
232229
233- self ::assertStringContainsString ($ writeLockSql , $ lastLoggedQuery );
230+ self ::assertStringContainsString (' FOR UPDATE ' , $ lastLoggedQuery );
234231 }
235232
236233 /** @group DDC-178 */
237234 public function testLockPessimisticRead (): void
238235 {
239- $ readLockSql = $ this ->_em ->getConnection ()->getDatabasePlatform ()->getReadLockSQL ();
240-
241- if (! $ readLockSql ) {
236+ if ($ this ->_em ->getConnection ()->getDatabasePlatform () instanceof SQLitePlatform) {
242237 self ::markTestSkipped ('Database Driver has no Write Lock support. ' );
243238 }
244239
@@ -264,7 +259,11 @@ public function testLockPessimisticRead(): void
264259 $ lastLoggedQuery = $ this ->getLastLoggedQuery (1 )['sql ' ];
265260 }
266261
267- self ::assertStringContainsString ($ readLockSql , $ lastLoggedQuery );
262+ self ::assertThat ($ lastLoggedQuery , self ::logicalOr (
263+ self ::stringContains ('FOR UPDATE ' ),
264+ self ::stringContains ('FOR SHARE ' ),
265+ self ::stringContains ('LOCK IN SHARE MODE ' )
266+ ));
268267 }
269268
270269 /** @group DDC-1693 */
0 commit comments