@@ -39,7 +39,7 @@ public function testItCanTryAcquireLockWithinSession(
39
39
accessMode: $ accessMode ,
40
40
);
41
41
42
- $ this ->assertTrue ($ isLockAcquired );
42
+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
43
43
$ this ->assertPgAdvisoryLocksCount (1 );
44
44
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId , $ accessMode );
45
45
}
@@ -71,7 +71,7 @@ public function testItCanTryAcquireLockWithinTransaction(
71
71
accessMode: $ accessMode ,
72
72
);
73
73
74
- $ this ->assertTrue ($ isLockAcquired );
74
+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
75
75
$ this ->assertPgAdvisoryLocksCount (1 );
76
76
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId , $ accessMode );
77
77
}
@@ -100,7 +100,7 @@ public function testItCanTryAcquireLockFromIntKeysCornerCases(): void
100
100
$ postgresLockId ,
101
101
);
102
102
103
- $ this ->assertTrue ($ isLockAcquired );
103
+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
104
104
$ this ->assertPgAdvisoryLocksCount (1 );
105
105
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId );
106
106
}
@@ -133,17 +133,17 @@ public function testItCanTryAcquireLockInSameConnectionOnlyOnce(): void
133
133
$ dbConnection = $ this ->initPostgresPdoConnection ();
134
134
$ postgresLockId = PostgresLockKey::create ('test ' );
135
135
136
- $ isLockAcquired1 = $ locker ->acquireSessionLevelLock (
136
+ $ isLock1Acquired = $ locker ->acquireSessionLevelLock (
137
137
$ dbConnection ,
138
138
$ postgresLockId ,
139
139
);
140
- $ isLockAcquired2 = $ locker ->acquireSessionLevelLock (
140
+ $ isLock2Acquired = $ locker ->acquireSessionLevelLock (
141
141
$ dbConnection ,
142
142
$ postgresLockId ,
143
143
);
144
144
145
- $ this ->assertTrue ($ isLockAcquired1 );
146
- $ this ->assertTrue ($ isLockAcquired2 );
145
+ $ this ->assertTrue ($ isLock1Acquired -> wasAcquired );
146
+ $ this ->assertTrue ($ isLock2Acquired -> wasAcquired );
147
147
$ this ->assertPgAdvisoryLocksCount (1 );
148
148
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId );
149
149
}
@@ -164,8 +164,8 @@ public function testItCanTryAcquireMultipleLocksInOneConnection(): void
164
164
$ postgresLockId2 ,
165
165
);
166
166
167
- $ this ->assertTrue ($ isLock1Acquired );
168
- $ this ->assertTrue ($ isLock2Acquired );
167
+ $ this ->assertTrue ($ isLock1Acquired-> wasAcquired );
168
+ $ this ->assertTrue ($ isLock2Acquired-> wasAcquired );
169
169
$ this ->assertPgAdvisoryLocksCount (2 );
170
170
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId1 );
171
171
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection , $ postgresLockId2 );
@@ -177,17 +177,18 @@ public function testItCannotAcquireSameLockInTwoConnections(): void
177
177
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
178
178
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
179
179
$ postgresLockId = PostgresLockKey::create ('test ' );
180
- $ locker ->acquireSessionLevelLock (
180
+ // TODO: Fix corner-case: without variable its self-destructing instantly
181
+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
181
182
$ dbConnection1 ,
182
183
$ postgresLockId ,
183
184
);
184
185
185
- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
186
+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
186
187
$ dbConnection2 ,
187
188
$ postgresLockId ,
188
189
);
189
190
190
- $ this ->assertFalse ($ isLockAcquired );
191
+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
191
192
$ this ->assertPgAdvisoryLocksCount (1 );
192
193
$ this ->assertPgAdvisoryLockMissingInConnection ($ dbConnection2 , $ postgresLockId );
193
194
}
@@ -199,7 +200,7 @@ public function testItCanReleaseLock(
199
200
$ locker = $ this ->initLocker ();
200
201
$ dbConnection = $ this ->initPostgresPdoConnection ();
201
202
$ postgresLockId = PostgresLockKey::create ('test ' );
202
- $ locker ->acquireSessionLevelLock (
203
+ $ connectionLock = $ locker ->acquireSessionLevelLock (
203
204
$ dbConnection ,
204
205
$ postgresLockId ,
205
206
accessMode: $ accessMode ,
@@ -235,7 +236,7 @@ public function testItCanNotReleaseLockOfDifferentModes(
235
236
$ locker = $ this ->initLocker ();
236
237
$ dbConnection = $ this ->initPostgresPdoConnection ();
237
238
$ postgresLockId = PostgresLockKey::create ('test ' );
238
- $ locker ->acquireSessionLevelLock (
239
+ $ connectionLock = $ locker ->acquireSessionLevelLock (
239
240
$ dbConnection ,
240
241
$ postgresLockId ,
241
242
accessMode: $ acquireMode ,
@@ -271,11 +272,11 @@ public function testItCanReleaseLockTwiceIfAcquiredTwice(): void
271
272
$ locker = $ this ->initLocker ();
272
273
$ dbConnection = $ this ->initPostgresPdoConnection ();
273
274
$ postgresLockId = PostgresLockKey::create ('test ' );
274
- $ locker ->acquireSessionLevelLock (
275
+ $ connectionLock1 = $ locker ->acquireSessionLevelLock (
275
276
$ dbConnection ,
276
277
$ postgresLockId ,
277
278
);
278
- $ locker ->acquireSessionLevelLock (
279
+ $ connectionLock2 = $ locker ->acquireSessionLevelLock (
279
280
$ dbConnection ,
280
281
$ postgresLockId ,
281
282
);
@@ -308,7 +309,7 @@ public function testItCanTryAcquireLockInSecondConnectionAfterRelease(): void
308
309
$ postgresLockId ,
309
310
);
310
311
311
- $ this ->assertTrue ($ isLockAcquired );
312
+ $ this ->assertTrue ($ isLockAcquired-> wasAcquired );
312
313
$ this ->assertPgAdvisoryLocksCount (1 );
313
314
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection2 , $ postgresLockId );
314
315
}
@@ -319,23 +320,23 @@ public function testItCannotAcquireLockInSecondConnectionAfterOneReleaseTwiceLoc
319
320
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
320
321
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
321
322
$ postgresLockId = PostgresLockKey::create ('test ' );
322
- $ locker ->acquireSessionLevelLock (
323
+ $ connection1Lock1 = $ locker ->acquireSessionLevelLock (
323
324
$ dbConnection1 ,
324
325
$ postgresLockId ,
325
326
);
326
- $ locker ->acquireSessionLevelLock (
327
+ $ connection1Lock2 = $ locker ->acquireSessionLevelLock (
327
328
$ dbConnection1 ,
328
329
$ postgresLockId ,
329
330
);
330
331
331
332
$ isLockReleased = $ locker ->releaseSessionLevelLock ($ dbConnection1 , $ postgresLockId );
332
- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
333
+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
333
334
$ dbConnection2 ,
334
335
$ postgresLockId ,
335
336
);
336
337
337
338
$ this ->assertTrue ($ isLockReleased );
338
- $ this ->assertFalse ($ isLockAcquired );
339
+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
339
340
$ this ->assertPgAdvisoryLocksCount (1 );
340
341
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection1 , $ postgresLockId );
341
342
$ this ->assertPgAdvisoryLockMissingInConnection ($ dbConnection2 , $ postgresLockId );
@@ -359,7 +360,7 @@ public function testItCannotReleaseLockIfAcquiredInOtherConnection(): void
359
360
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
360
361
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
361
362
$ postgresLockId = PostgresLockKey::create ('test ' );
362
- $ locker ->acquireSessionLevelLock (
363
+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
363
364
$ dbConnection1 ,
364
365
$ postgresLockId ,
365
366
);
@@ -412,19 +413,19 @@ public function testItCanReleaseAllLocksInConnectionButKeepsOtherConnectionLocks
412
413
$ postgresLockId2 = PostgresLockKey::create ('test2 ' );
413
414
$ postgresLockId3 = PostgresLockKey::create ('test3 ' );
414
415
$ postgresLockId4 = PostgresLockKey::create ('test4 ' );
415
- $ locker ->acquireSessionLevelLock (
416
+ $ connect1Lock1 = $ locker ->acquireSessionLevelLock (
416
417
$ dbConnection1 ,
417
418
$ postgresLockId1 ,
418
419
);
419
- $ locker ->acquireSessionLevelLock (
420
+ $ connect1Lock2 = $ locker ->acquireSessionLevelLock (
420
421
$ dbConnection1 ,
421
422
$ postgresLockId2 ,
422
423
);
423
- $ locker ->acquireSessionLevelLock (
424
+ $ connect2Lock3 = $ locker ->acquireSessionLevelLock (
424
425
$ dbConnection2 ,
425
426
$ postgresLockId3 ,
426
427
);
427
- $ locker ->acquireSessionLevelLock (
428
+ $ connect2Lock4 = $ locker ->acquireSessionLevelLock (
428
429
$ dbConnection2 ,
429
430
$ postgresLockId4 ,
430
431
);
@@ -460,17 +461,17 @@ public function testItCannotAcquireLockInSecondConnectionIfTakenWithinTransactio
460
461
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
461
462
$ postgresLockId = PostgresLockKey::create ('test ' );
462
463
$ dbConnection1 ->beginTransaction ();
463
- $ locker ->acquireSessionLevelLock (
464
+ $ connection1Lock = $ locker ->acquireSessionLevelLock (
464
465
$ dbConnection1 ,
465
466
$ postgresLockId ,
466
467
);
467
468
468
- $ isLockAcquired = $ locker ->acquireSessionLevelLock (
469
+ $ connection2Lock = $ locker ->acquireSessionLevelLock (
469
470
$ dbConnection2 ,
470
471
$ postgresLockId ,
471
472
);
472
473
473
- $ this ->assertFalse ($ isLockAcquired );
474
+ $ this ->assertFalse ($ connection2Lock -> wasAcquired );
474
475
$ this ->assertPgAdvisoryLocksCount (1 );
475
476
$ this ->assertPgAdvisoryLockExistsInConnection ($ dbConnection1 , $ postgresLockId );
476
477
}
0 commit comments