test(tests): replace $this->fail with caught exception assertion in LaravelCacheLockTest

This commit is contained in:
Jérémy Munsch 2026-11-16 13:11:20 +01:00
parent 348119ec7c
commit 8b9eb59b50
No known key found for this signature in database
GPG key ID: 2AAECDA6B7330F91

View file

@ -91,13 +91,17 @@ describe('LaravelCacheLock', function (): void {
$cacheLock = new LaravelCacheLock($cache);
// WHEN
$caught = null;
try {
$cacheLock->synchronize('test:lock:wrapped', fn (): string => 'never', 30, 5);
$this->fail('Expected LockTimeoutException was not thrown.');
} catch (LockTimeoutException $e) {
// THEN
expect($e->getMessage())->toBe('Timed out')
->and($e->getPrevious())->toBeInstanceOf(LaravelLockTimeoutException::class);
$caught = $e;
}
// THEN
expect($caught)->toBeInstanceOf(LockTimeoutException::class)
->and($caught?->getMessage())->toBe('Timed out')
->and($caught?->getPrevious())->toBeInstanceOf(LaravelLockTimeoutException::class);
});
});