Skip to content

Commit

Permalink
more void
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 3, 2024
1 parent 7b7a173 commit 39565c4
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 49 deletions.
8 changes: 4 additions & 4 deletions tests/mutex/CASMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void
/**
* Tests exceeding the execution timeout.
*/
public function testExceedTimeout()
public function testExceedTimeout(): void
{
$this->expectException(LockAcquireException::class);

Expand All @@ -41,7 +41,7 @@ public function testExceedTimeout()
/**
* Tests that an exception would stop any further iteration.
*/
public function testExceptionStopsIteration()
public function testExceptionStopsIteration(): void
{
$this->expectException(\DomainException::class);

Expand All @@ -54,7 +54,7 @@ public function testExceptionStopsIteration()
/**
* Tests notify() will stop the iteration and return the result.
*/
public function testNotify()
public function testNotify(): void
{
$i = 0;
$mutex = new CASMutex();
Expand All @@ -68,7 +68,7 @@ public function testNotify()
/**
* Tests that the code is executed more times.
*/
public function testIteration()
public function testIteration(): void
{
$i = 0;
$mutex = new CASMutex();
Expand Down
2 changes: 1 addition & 1 deletion tests/mutex/FlockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function dpTimeoutableStrategiesCases(): iterable
];
}

public function testNoTimeoutWaitsForever()
public function testNoTimeoutWaitsForever(): void
{
$this->expectException(DeadlineException::class);

Expand Down
14 changes: 7 additions & 7 deletions tests/mutex/LockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp(): void
/**
* Tests lock() fails and the code is not executed.
*/
public function testLockFails()
public function testLockFails(): void
{
$this->expectException(LockAcquireException::class);

Expand All @@ -39,7 +39,7 @@ public function testLockFails()
/**
* Tests unlock() is called after the code was executed.
*/
public function testUnlockAfterCode()
public function testUnlockAfterCode(): void
{
$this->mutex->expects(self::once())
->method('unlock');
Expand All @@ -50,7 +50,7 @@ public function testUnlockAfterCode()
/**
* Tests unlock() is called after an exception.
*/
public function testUnlockAfterException()
public function testUnlockAfterException(): void
{
$this->mutex->expects(self::once())
->method('unlock');
Expand All @@ -64,7 +64,7 @@ public function testUnlockAfterException()
/**
* Tests unlock() fails after the code was executed.
*/
public function testUnlockFailsAfterCode()
public function testUnlockFailsAfterCode(): void
{
$this->expectException(LockReleaseException::class);

Expand All @@ -78,7 +78,7 @@ public function testUnlockFailsAfterCode()
/**
* Tests unlock() fails after the code threw an exception.
*/
public function testUnlockFailsAfterException()
public function testUnlockFailsAfterException(): void
{
$this->expectException(LockReleaseException::class);

Expand All @@ -94,7 +94,7 @@ public function testUnlockFailsAfterException()
/**
* Tests the code result is available in LockReleaseException.
*/
public function testCodeResultAvailableAfterFailedUnlock()
public function testCodeResultAvailableAfterFailedUnlock(): void
{
$this->mutex->expects(self::once())
->method('unlock')
Expand All @@ -113,7 +113,7 @@ public function testCodeResultAvailableAfterFailedUnlock()
/**
* Tests the code exception is available in LockReleaseException.
*/
public function testCodeExceptionAvailableAfterFailedUnlock()
public function testCodeExceptionAvailableAfterFailedUnlock(): void
{
$this->mutex->expects(self::once())
->method('unlock')
Expand Down
4 changes: 2 additions & 2 deletions tests/mutex/MemcachedMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp(): void
/**
* Tests failing to acquire the lock within the timeout.
*/
public function testFailAcquireLock()
public function testFailAcquireLock(): void
{
$this->expectException(TimeoutException::class);

Expand All @@ -49,7 +49,7 @@ public function testFailAcquireLock()
/**
* Tests failing to release a lock.
*/
public function testFailReleasingLock()
public function testFailReleasingLock(): void
{
$this->expectException(LockReleaseException::class);

Expand Down
8 changes: 4 additions & 4 deletions tests/mutex/PHPRedisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private function closeMinorityConnections()
}
}

public function testAddFails()
public function testAddFails(): void
{
$this->expectException(LockAcquireException::class);
$this->expectExceptionCode(MutexException::REDIS_NOT_ENOUGH_SERVERS);
Expand All @@ -167,7 +167,7 @@ public function testAddFails()
/**
* Tests evalScript() fails.
*/
public function testEvalScriptFails()
public function testEvalScriptFails(): void
{
$this->expectException(LockReleaseException::class);

Expand All @@ -191,7 +191,7 @@ public function testSerializersAndCompressors($serializer, $compressor): void
}));
}

public function testResistantToPartialClusterFailuresForAcquiringLock()
public function testResistantToPartialClusterFailuresForAcquiringLock(): void
{
$this->closeMinorityConnections();

Expand All @@ -200,7 +200,7 @@ public function testResistantToPartialClusterFailuresForAcquiringLock()
}));
}

public function testResistantToPartialClusterFailuresForReleasingLock()
public function testResistantToPartialClusterFailuresForReleasingLock(): void
{
self::assertNull($this->mutex->synchronized(function () { // @phpstan-ignore staticMethod.alreadyNarrowedType
$this->closeMinorityConnections();
Expand Down
4 changes: 2 additions & 2 deletions tests/mutex/PgAdvisoryLockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp(): void
$this->mutex = new PgAdvisoryLockMutex($this->pdo, 'test' . uniqid());
}

public function testAcquireLock()
public function testAcquireLock(): void
{
$statement = $this->createMock(\PDOStatement::class);

Expand Down Expand Up @@ -53,7 +53,7 @@ public function testAcquireLock()
$this->mutex->lock();
}

public function testReleaseLock()
public function testReleaseLock(): void
{
$statement = $this->createMock(\PDOStatement::class);

Expand Down
8 changes: 4 additions & 4 deletions tests/mutex/PredisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
/**
* Tests add() fails.
*/
public function testAddFailsToSetKey()
public function testAddFailsToSetKey(): void
{
$this->client->expects(self::atLeastOnce())
->method('set')
Expand All @@ -66,7 +66,7 @@ static function (): void {
/**
* Tests add() errors.
*/
public function testAddErrors()
public function testAddErrors(): void
{
$this->client->expects(self::atLeastOnce())
->method('set')
Expand All @@ -86,7 +86,7 @@ static function () {
);
}

public function testWorksNormally()
public function testWorksNormally(): void
{
$this->client->expects(self::atLeastOnce())
->method('set')
Expand All @@ -110,7 +110,7 @@ public function testWorksNormally()
/**
* Tests evalScript() fails.
*/
public function testEvalScriptFails()
public function testEvalScriptFails(): void
{
$this->client->expects(self::atLeastOnce())
->method('set')
Expand Down
12 changes: 6 additions & 6 deletions tests/mutex/SpinlockMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp(): void
/**
* Tests failing to acquire the lock.
*/
public function testFailAcquireLock()
public function testFailAcquireLock(): void
{
$this->expectException(LockAcquireException::class);

Expand All @@ -49,7 +49,7 @@ public function testFailAcquireLock()
/**
* Tests failing to acquire the lock due to a timeout.
*/
public function testAcquireTimesOut()
public function testAcquireTimesOut(): void
{
$this->expectException(TimeoutException::class);
$this->expectExceptionMessage('Timeout of 3.0 seconds exceeded.');
Expand All @@ -67,7 +67,7 @@ public function testAcquireTimesOut()
/**
* Tests executing code which exceeds the timeout fails.
*/
public function testExecuteTooLong()
public function testExecuteTooLong(): void
{
/** @var SpinlockMutex|MockObject $mutex */
$mutex = $this->getMockForAbstractClass(SpinlockMutex::class, ['test', 0.5]); // @phpstan-ignore varTag.nativeType
Expand All @@ -93,7 +93,7 @@ public function testExecuteTooLong()
/**
* Tests executing code which barely doesn't hit the timeout.
*/
public function testExecuteBarelySucceeds()
public function testExecuteBarelySucceeds(): void
{
$mutex = $this->getMockForAbstractClass(SpinlockMutex::class, ['test', 0.5]);
$mutex->expects(self::any())->method('acquire')->willReturn(true);
Expand All @@ -107,7 +107,7 @@ public function testExecuteBarelySucceeds()
/**
* Tests failing to release a lock.
*/
public function testFailReleasingLock()
public function testFailReleasingLock(): void
{
$this->expectException(LockReleaseException::class);

Expand All @@ -121,7 +121,7 @@ public function testFailReleasingLock()
/**
* Tests executing exactly until the timeout will leave the key one more second.
*/
public function testExecuteTimeoutLeavesOneSecondForKeyToExpire()
public function testExecuteTimeoutLeavesOneSecondForKeyToExpire(): void
{
$mutex = $this->getMockForAbstractClass(SpinlockMutex::class, ['test', 0.2]);
$mutex->expects(self::once())
Expand Down
8 changes: 4 additions & 4 deletions tests/mutex/TransactionalMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function provideInvalidErrorModeCases(): iterable
/**
* Tests BEGIN fails.
*/
public function testBeginFails()
public function testBeginFails(): void
{
$this->expectException(LockAcquireException::class);
$this->expectExceptionMessage('Could not begin transaction.');
Expand All @@ -60,7 +60,7 @@ public function testBeginFails()
/**
* Tests that an exception in the critical code causes a ROLLBACK.
*/
public function testExceptionRollsback()
public function testExceptionRollsback(): void
{
$pdo = $this->buildMySqlPdo();
$mutex = new TransactionalMutex($pdo);
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testExceptionRollsback()
/**
* Tests that a ROLLBACK caused by an exception fails.
*/
public function testFailExceptionRollsback()
public function testFailExceptionRollsback(): void
{
$pdo = $this->buildMySqlPdo();
$mutex = new TransactionalMutex($pdo);
Expand Down Expand Up @@ -158,7 +158,7 @@ public static function provideReplayTransactionCases(): iterable
/**
* Tests failing a ROLLBACK after the failed COMMIT.
*/
public function testRollbackAfterFailedCommitFails()
public function testRollbackAfterFailedCommitFails(): void
{
$this->expectException(LockAcquireException::class);
$this->expectExceptionMessage('Could not roll back transaction:');
Expand Down
6 changes: 3 additions & 3 deletions tests/util/DoubleCheckedLockingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function setUp(): void
/**
* Tests that the lock will not be acquired for a failing test.
*/
public function testCheckFailsAcquiresNoLock()
public function testCheckFailsAcquiresNoLock(): void
{
$this->mutex->expects(self::never())->method('synchronized');

Expand All @@ -41,7 +41,7 @@ public function testCheckFailsAcquiresNoLock()
/**
* Tests that the check and execution are in the same lock.
*/
public function testLockedCheckAndExecution()
public function testLockedCheckAndExecution(): void
{
$lock = 0;
$check = 0;
Expand Down Expand Up @@ -127,7 +127,7 @@ public static function provideCodeNotExecutedCases(): iterable
/**
* Tests that the code executed if the checks are true.
*/
public function testCodeExecuted()
public function testCodeExecuted(): void
{
$this->mutex->expects(self::once())
->method('synchronized')
Expand Down
Loading

0 comments on commit 39565c4

Please sign in to comment.