@@ -39,7 +39,7 @@ public function testItCanTryAcquireLockWithinSession(
3939 accessMode: $ accessMode ,
4040 );
4141
42- $ this ->assertTrue ($ isLockAcquired );
42+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
4343 $ this ->assertPgAdvisoryLocksCount (1 );
4444 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId , $ accessMode );
4545 }
@@ -71,7 +71,7 @@ public function testItCanTryAcquireLockWithinTransaction(
7171 accessMode: $ accessMode ,
7272 );
7373
74- $ this ->assertTrue ($ isLockAcquired );
74+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
7575 $ this ->assertPgAdvisoryLocksCount (1 );
7676 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId , $ accessMode );
7777 }
@@ -100,7 +100,7 @@ public function testItCanTryAcquireLockFromIntKeysCornerCases(): void
100100 $ postgresLockId ,
101101 );
102102
103- $ this ->assertTrue ($ isLockAcquired );
103+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
104104 $ this ->assertPgAdvisoryLocksCount (1 );
105105 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId );
106106 }
@@ -133,17 +133,17 @@ public function testItCanTryAcquireLockInSameConnectionOnlyOnce(): void
133133 $ dbConnection = $ this ->initPostgresPdoConnection ();
134134 $ postgresLockId = PostgresLockKey::create ('test ' );
135135
136- $ isLockAcquired1 = $ locker ->acquireSessionLevelLock (
136+ $ isLock1Acquired = $ locker ->acquireSessionLevelLock (
137137 $ dbConnection ,
138138 $ postgresLockId ,
139139 );
140- $ isLockAcquired2 = $ locker ->acquireSessionLevelLock (
140+ $ isLock2Acquired = $ locker ->acquireSessionLevelLock (
141141 $ dbConnection ,
142142 $ postgresLockId ,
143143 );
144144
145- $ this ->assertTrue ($ isLockAcquired1 );
146- $ this ->assertTrue ($ isLockAcquired2 );
145+ $ this ->assertTrue ($ isLock1Acquired -> wasAcquired );
146+ $ this ->assertTrue ($ isLock2Acquired -> wasAcquired );
147147 $ this ->assertPgAdvisoryLocksCount (1 );
148148 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId );
149149 }
@@ -164,8 +164,8 @@ public function testItCanTryAcquireMultipleLocksInOneConnection(): void
164164 $ postgresLockId2 ,
165165 );
166166
167- $ this ->assertTrue ($ isLock1Acquired );
168- $ this ->assertTrue ($ isLock2Acquired );
167+ $ this ->assertTrue ($ isLock1Acquired-> wasAcquired );
168+ $ this ->assertTrue ($ isLock2Acquired-> wasAcquired );
169169 $ this ->assertPgAdvisoryLocksCount (2 );
170170 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId1 );
171171 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId2 );
@@ -177,17 +177,18 @@ public function testItCannotAcquireSameLockInTwoConnections(): void
177177 $ dbConnection1 = $ this ->initPostgresPdoConnection ();
178178 $ dbConnection2 = $ this ->initPostgresPdoConnection ();
179179 $ postgresLockId = PostgresLockKey::create ('test ' );
180- $ locker ->acquireSessionLevelLock (
180+ // TODO: Fix corner-case: without variable its self-destructing instantly
181+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
181182 $ dbConnection1 ,
182183 $ postgresLockId ,
183184 );
184185
185- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
186+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
186187 $ dbConnection2 ,
187188 $ postgresLockId ,
188189 );
189190
190- $ this ->assertFalse ($ isLockAcquired );
191+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
191192 $ this ->assertPgAdvisoryLocksCount (1 );
192193 $ this ->assertPgAdvisoryLockMissingInConnection ($ dbConnection2 , $ postgresLockId );
193194 }
@@ -199,7 +200,7 @@ public function testItCanReleaseLock(
199200 $ locker = $ this ->initLocker ();
200201 $ dbConnection = $ this ->initPostgresPdoConnection ();
201202 $ postgresLockId = PostgresLockKey::create ('test ' );
202- $ locker ->acquireSessionLevelLock (
203+ $ connectionLock = $ locker ->acquireSessionLevelLock (
203204 $ dbConnection ,
204205 $ postgresLockId ,
205206 accessMode: $ accessMode ,
@@ -235,7 +236,7 @@ public function testItCanNotReleaseLockOfDifferentModes(
235236 $ locker = $ this ->initLocker ();
236237 $ dbConnection = $ this ->initPostgresPdoConnection ();
237238 $ postgresLockId = PostgresLockKey::create ('test ' );
238- $ locker ->acquireSessionLevelLock (
239+ $ connectionLock = $ locker ->acquireSessionLevelLock (
239240 $ dbConnection ,
240241 $ postgresLockId ,
241242 accessMode: $ acquireMode ,
@@ -271,11 +272,11 @@ public function testItCanReleaseLockTwiceIfAcquiredTwice(): void
271272 $ locker = $ this ->initLocker ();
272273 $ dbConnection = $ this ->initPostgresPdoConnection ();
273274 $ postgresLockId = PostgresLockKey::create ('test ' );
274- $ locker ->acquireSessionLevelLock (
275+ $ connectionLock1 = $ locker ->acquireSessionLevelLock (
275276 $ dbConnection ,
276277 $ postgresLockId ,
277278 );
278- $ locker ->acquireSessionLevelLock (
279+ $ connectionLock2 = $ locker ->acquireSessionLevelLock (
279280 $ dbConnection ,
280281 $ postgresLockId ,
281282 );
@@ -308,7 +309,7 @@ public function testItCanTryAcquireLockInSecondConnectionAfterRelease(): void
308309 $ postgresLockId ,
309310 );
310311
311- $ this ->assertTrue ($ isLockAcquired );
312+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
312313 $ this ->assertPgAdvisoryLocksCount (1 );
313314 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection2 , $ postgresLockId );
314315 }
@@ -319,23 +320,23 @@ public function testItCannotAcquireLockInSecondConnectionAfterOneReleaseTwiceLoc
319320 $ dbConnection1 = $ this ->initPostgresPdoConnection ();
320321 $ dbConnection2 = $ this ->initPostgresPdoConnection ();
321322 $ postgresLockId = PostgresLockKey::create ('test ' );
322- $ locker ->acquireSessionLevelLock (
323+ $ connection1Lock1 = $ locker ->acquireSessionLevelLock (
323324 $ dbConnection1 ,
324325 $ postgresLockId ,
325326 );
326- $ locker ->acquireSessionLevelLock (
327+ $ connection1Lock2 = $ locker ->acquireSessionLevelLock (
327328 $ dbConnection1 ,
328329 $ postgresLockId ,
329330 );
330331
331332 $ isLockReleased = $ locker ->releaseSessionLevelLock ($ dbConnection1 , $ postgresLockId );
332- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
333+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
333334 $ dbConnection2 ,
334335 $ postgresLockId ,
335336 );
336337
337338 $ this ->assertTrue ($ isLockReleased );
338- $ this ->assertFalse ($ isLockAcquired );
339+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
339340 $ this ->assertPgAdvisoryLocksCount (1 );
340341 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection1 , $ postgresLockId );
341342 $ this ->assertPgAdvisoryLockMissingInConnection ($ dbConnection2 , $ postgresLockId );
@@ -359,7 +360,7 @@ public function testItCannotReleaseLockIfAcquiredInOtherConnection(): void
359360 $ dbConnection1 = $ this ->initPostgresPdoConnection ();
360361 $ dbConnection2 = $ this ->initPostgresPdoConnection ();
361362 $ postgresLockId = PostgresLockKey::create ('test ' );
362- $ locker ->acquireSessionLevelLock (
363+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
363364 $ dbConnection1 ,
364365 $ postgresLockId ,
365366 );
@@ -412,19 +413,19 @@ public function testItCanReleaseAllLocksInConnectionButKeepsOtherConnectionLocks
412413 $ postgresLockId2 = PostgresLockKey::create ('test2 ' );
413414 $ postgresLockId3 = PostgresLockKey::create ('test3 ' );
414415 $ postgresLockId4 = PostgresLockKey::create ('test4 ' );
415- $ locker ->acquireSessionLevelLock (
416+ $ connect1Lock1 = $ locker ->acquireSessionLevelLock (
416417 $ dbConnection1 ,
417418 $ postgresLockId1 ,
418419 );
419- $ locker ->acquireSessionLevelLock (
420+ $ connect1Lock2 = $ locker ->acquireSessionLevelLock (
420421 $ dbConnection1 ,
421422 $ postgresLockId2 ,
422423 );
423- $ locker ->acquireSessionLevelLock (
424+ $ connect2Lock3 = $ locker ->acquireSessionLevelLock (
424425 $ dbConnection2 ,
425426 $ postgresLockId3 ,
426427 );
427- $ locker ->acquireSessionLevelLock (
428+ $ connect2Lock4 = $ locker ->acquireSessionLevelLock (
428429 $ dbConnection2 ,
429430 $ postgresLockId4 ,
430431 );
@@ -460,17 +461,17 @@ public function testItCannotAcquireLockInSecondConnectionIfTakenWithinTransactio
460461 $ dbConnection2 = $ this ->initPostgresPdoConnection ();
461462 $ postgresLockId = PostgresLockKey::create ('test ' );
462463 $ dbConnection1 ->beginTransaction ();
463- $ locker ->acquireSessionLevelLock (
464+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
464465 $ dbConnection1 ,
465466 $ postgresLockId ,
466467 );
467468
468- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
469+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
469470 $ dbConnection2 ,
470471 $ postgresLockId ,
471472 );
472473
473- $ this ->assertFalse ($ isLockAcquired );
474+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
474475 $ this ->assertPgAdvisoryLocksCount (1 );
475476 $ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection1 , $ postgresLockId );
476477 }
0 commit comments