test(tests): replace $this->fail with caught exception assertion in LaravelCacheLockTest
This commit is contained in:
parent
348119ec7c
commit
8b9eb59b50
1 changed files with 8 additions and 4 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue