Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aca8342

Browse files
Add more transaction-level negative tests
1 parent f8bab28 commit aca8342

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

‎test/Integration/Locker/PostgresAdvisoryLockerTest.php‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,49 @@ public function it_cannot_acquire_lock_in_second_connection_if_taken_within_tran
310310
}
311311

312312
/** @test */
313-
public function it_can_auto_release_lock_acquired_within_transaction(): void
313+
public function it_can_auto_release_lock_acquired_within_transaction_on_commit(): void
314314
{
315315
$locker = $this->createLocker();
316316
$dbConnection = $this->createPostgresPdoConnection();
317317
$postgresLockId = $this->createPostgresLockId('test');
318318
$dbConnection->beginTransaction();
319+
$locker->acquireLockWithinTransaction($dbConnection, $postgresLockId);
319320

320-
$isLockAcquired = $locker->acquireLockWithinTransaction($dbConnection, $postgresLockId);
321321
$dbConnection->commit();
322322

323-
$this->assertTrue($isLockAcquired);
324323
$this->assertPgAdvisoryLocksCount(0);
325324
$this->assertPgAdvisoryLockMissingInConnection($dbConnection, $postgresLockId);
326325
}
327326

327+
/** @test */
328+
public function it_can_auto_release_lock_acquired_within_transaction_on_rollback(): void
329+
{
330+
$locker = $this->createLocker();
331+
$dbConnection = $this->createPostgresPdoConnection();
332+
$postgresLockId = $this->createPostgresLockId('test');
333+
$dbConnection->beginTransaction();
334+
$locker->acquireLockWithinTransaction($dbConnection, $postgresLockId);
335+
336+
$dbConnection->rollBack();
337+
338+
$this->assertPgAdvisoryLocksCount(0);
339+
$this->assertPgAdvisoryLockMissingInConnection($dbConnection, $postgresLockId);
340+
}
341+
342+
/** @test */
343+
public function it_can_auto_release_lock_acquired_within_transaction_on_connection_kill(): void
344+
{
345+
$locker = $this->createLocker();
346+
$dbConnection = $this->createPostgresPdoConnection();
347+
$postgresLockId = $this->createPostgresLockId('test');
348+
$dbConnection->beginTransaction();
349+
$locker->acquireLockWithinTransaction($dbConnection, $postgresLockId);
350+
351+
$dbConnection = null;
352+
353+
$this->assertPgAdvisoryLocksCount(0);
354+
}
355+
328356
/** @test */
329357
public function it_cannot_release_lock_acquired_within_transaction(): void
330358
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /