@@ -30,7 +30,7 @@ public function testItCanTryAcquireLockWithinSession(): void
30
30
$ dbConnection = $ this ->initPostgresPdoConnection ();
31
31
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
32
32
33
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
33
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
34
34
35
35
$ this ->assertTrue ($ isLockAcquired );
36
36
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -44,7 +44,7 @@ public function testItCanTryAcquireLockFromIntKeysCornerCases(): void
44
44
$ dbConnection = $ this ->initPostgresPdoConnection ();
45
45
$ postgresLockId = PostgresLockId::fromIntKeys (self ::DB_INT32_VALUE_MIN , 0 );
46
46
47
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
47
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
48
48
49
49
$ this ->assertTrue ($ isLockAcquired );
50
50
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -79,8 +79,8 @@ public function testItCanTryAcquireLockInSameConnectionOnlyOnce(): void
79
79
$ dbConnection = $ this ->initPostgresPdoConnection ();
80
80
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
81
81
82
- $ isLockAcquired1 = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
83
- $ isLockAcquired2 = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
82
+ $ isLockAcquired1 = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
83
+ $ isLockAcquired2 = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
84
84
85
85
$ this ->assertTrue ($ isLockAcquired1 );
86
86
$ this ->assertTrue ($ isLockAcquired2 );
@@ -95,8 +95,8 @@ public function testItCanTryAcquireMultipleLocksInOneConnection(): void
95
95
$ postgresLockId1 = PostgresLockId::fromKeyValue ('test1 ' );
96
96
$ postgresLockId2 = PostgresLockId::fromKeyValue ('test2 ' );
97
97
98
- $ isLock1Acquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
99
- $ isLock2Acquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId2 );
98
+ $ isLock1Acquired = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
99
+ $ isLock2Acquired = $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId2 );
100
100
101
101
$ this ->assertTrue ($ isLock1Acquired );
102
102
$ this ->assertTrue ($ isLock2Acquired );
@@ -111,9 +111,9 @@ public function testItCannotAcquireSameLockInTwoConnections(): void
111
111
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
112
112
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
113
113
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
114
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
114
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
115
115
116
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
116
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
117
117
118
118
$ this ->assertFalse ($ isLockAcquired );
119
119
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -125,7 +125,7 @@ public function testItCanReleaseLock(): void
125
125
$ locker = $ this ->initLocker ();
126
126
$ dbConnection = $ this ->initPostgresPdoConnection ();
127
127
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
128
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
128
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
129
129
130
130
$ isLockReleased = $ locker ->releaseLockWithinSession ($ dbConnection , $ postgresLockId );
131
131
@@ -138,8 +138,8 @@ public function testItCanReleaseLockTwiceIfAcquiredTwice(): void
138
138
$ locker = $ this ->initLocker ();
139
139
$ dbConnection = $ this ->initPostgresPdoConnection ();
140
140
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
141
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
142
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId );
141
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
142
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId );
143
143
144
144
$ isLockReleased1 = $ locker ->releaseLockWithinSession ($ dbConnection , $ postgresLockId );
145
145
$ isLockReleased2 = $ locker ->releaseLockWithinSession ($ dbConnection , $ postgresLockId );
@@ -155,10 +155,10 @@ public function testItCanTryAcquireLockInSecondConnectionAfterRelease(): void
155
155
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
156
156
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
157
157
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
158
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
158
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
159
159
$ locker ->releaseLockWithinSession ($ dbConnection1 , $ postgresLockId );
160
160
161
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
161
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
162
162
163
163
$ this ->assertTrue ($ isLockAcquired );
164
164
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -171,11 +171,11 @@ public function testItCannotAcquireLockInSecondConnectionAfterOneReleaseTwiceLoc
171
171
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
172
172
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
173
173
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
174
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
175
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
174
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
175
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
176
176
177
177
$ isLockReleased = $ locker ->releaseLockWithinSession ($ dbConnection1 , $ postgresLockId );
178
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
178
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
179
179
180
180
$ this ->assertTrue ($ isLockReleased );
181
181
$ this ->assertFalse ($ isLockAcquired );
@@ -202,7 +202,7 @@ public function testItCannotReleaseLockIfAcquiredInOtherConnection(): void
202
202
$ dbConnection1 = $ this ->initPostgresPdoConnection ();
203
203
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
204
204
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
205
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
205
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId );
206
206
207
207
$ isLockReleased = $ locker ->releaseLockWithinSession ($ dbConnection2 , $ postgresLockId );
208
208
@@ -217,8 +217,8 @@ public function testItCanReleaseAllLocksInConnection(): void
217
217
$ dbConnection = $ this ->initPostgresPdoConnection ();
218
218
$ postgresLockId1 = PostgresLockId::fromKeyValue ('test ' );
219
219
$ postgresLockId2 = PostgresLockId::fromKeyValue ('test2 ' );
220
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
221
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId2 );
220
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
221
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId2 );
222
222
223
223
$ locker ->releaseAllLocksWithinSession ($ dbConnection );
224
224
@@ -244,10 +244,10 @@ public function testItCanReleaseAllLocksInConnectionButKeepsOtherLocks(): void
244
244
$ postgresLockId2 = PostgresLockId::fromKeyValue ('test2 ' );
245
245
$ postgresLockId3 = PostgresLockId::fromKeyValue ('test3 ' );
246
246
$ postgresLockId4 = PostgresLockId::fromKeyValue ('test4 ' );
247
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId1 );
248
- $ locker ->tryAcquireLockWithinSession ($ dbConnection1 , $ postgresLockId2 );
249
- $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId3 );
250
- $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId4 );
247
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId1 );
248
+ $ locker ->acquireLockWithinSession ($ dbConnection1 , $ postgresLockId2 );
249
+ $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId3 );
250
+ $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId4 );
251
251
252
252
$ locker ->releaseAllLocksWithinSession ($ dbConnection1 );
253
253
@@ -263,7 +263,7 @@ public function testItCanTryAcquireLockWithinTransaction(): void
263
263
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
264
264
$ dbConnection ->beginTransaction ();
265
265
266
- $ isLockAcquired = $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
266
+ $ isLockAcquired = $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
267
267
268
268
$ this ->assertTrue ($ isLockAcquired );
269
269
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -281,7 +281,7 @@ public function testItCannotAcquireLockWithinTransactionNotInTransaction(): void
281
281
$ dbConnection = $ this ->initPostgresPdoConnection ();
282
282
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
283
283
284
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
284
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
285
285
}
286
286
287
287
public function testItCannotAcquireLockInSecondConnectionIfTakenWithinTransaction (): void
@@ -291,9 +291,9 @@ public function testItCannotAcquireLockInSecondConnectionIfTakenWithinTransactio
291
291
$ dbConnection2 = $ this ->initPostgresPdoConnection ();
292
292
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
293
293
$ dbConnection1 ->beginTransaction ();
294
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection1 , $ postgresLockId );
294
+ $ locker ->acquireLockWithinTransaction ($ dbConnection1 , $ postgresLockId );
295
295
296
- $ isLockAcquired = $ locker ->tryAcquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
296
+ $ isLockAcquired = $ locker ->acquireLockWithinSession ($ dbConnection2 , $ postgresLockId );
297
297
298
298
$ this ->assertFalse ($ isLockAcquired );
299
299
$ this ->assertPgAdvisoryLocksCount (1 );
@@ -306,7 +306,7 @@ public function testItCanAutoReleaseLockAcquiredWithinTransactionOnCommit(): voi
306
306
$ dbConnection = $ this ->initPostgresPdoConnection ();
307
307
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
308
308
$ dbConnection ->beginTransaction ();
309
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
309
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
310
310
311
311
$ dbConnection ->commit ();
312
312
@@ -320,7 +320,7 @@ public function testItCanAutoReleaseLockAcquiredWithinTransactionOnRollback(): v
320
320
$ dbConnection = $ this ->initPostgresPdoConnection ();
321
321
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
322
322
$ dbConnection ->beginTransaction ();
323
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
323
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
324
324
325
325
$ dbConnection ->rollBack ();
326
326
@@ -334,7 +334,7 @@ public function testItCanAutoReleaseLockAcquiredWithinTransactionOnConnectionKil
334
334
$ dbConnection = $ this ->initPostgresPdoConnection ();
335
335
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
336
336
$ dbConnection ->beginTransaction ();
337
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
337
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
338
338
339
339
$ dbConnection = null ;
340
340
@@ -347,7 +347,7 @@ public function testItCannotReleaseLockAcquiredWithinTransaction(): void
347
347
$ dbConnection = $ this ->initPostgresPdoConnection ();
348
348
$ postgresLockId = PostgresLockId::fromKeyValue ('test ' );
349
349
$ dbConnection ->beginTransaction ();
350
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
350
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId );
351
351
352
352
$ isLockReleased = $ locker ->releaseLockWithinSession ($ dbConnection , $ postgresLockId );
353
353
@@ -362,9 +362,9 @@ public function testItCannotReleaseAllLocksAcquiredWithinTransaction(): void
362
362
$ dbConnection = $ this ->initPostgresPdoConnection ();
363
363
$ postgresLockId1 = PostgresLockId::fromKeyValue ('test ' );
364
364
$ postgresLockId2 = PostgresLockId::fromKeyValue ('test2 ' );
365
- $ locker ->tryAcquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
365
+ $ locker ->acquireLockWithinSession ($ dbConnection , $ postgresLockId1 );
366
366
$ dbConnection ->beginTransaction ();
367
- $ locker ->tryAcquireLockWithinTransaction ($ dbConnection , $ postgresLockId2 );
367
+ $ locker ->acquireLockWithinTransaction ($ dbConnection , $ postgresLockId2 );
368
368
369
369
$ locker ->releaseAllLocksWithinSession ($ dbConnection );
370
370
0 commit comments