Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denisyukphp committed Apr 24, 2021
1 parent 6a18e14 commit 7c09600
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 46 deletions.
6 changes: 3 additions & 3 deletions tests/BackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testMaxAttemptsSuccess(): void

$backoffTime = $backoff->generate(4);

$this->assertEquals(5000, $backoffTime->toMilliseconds());
$this->assertEquals(5000, $backoffTime->asMilliseconds());
}

public function testMaxAttemptsFail(): void
Expand All @@ -48,7 +48,7 @@ public function testCapTime(): void

$backoffTime = $backoff->generate(1);

$this->assertEquals(1000 * 60, $backoffTime->toMilliseconds());
$this->assertEquals(1000 * 60, $backoffTime->asMilliseconds());
}

public function testJitterTime(): void
Expand All @@ -64,6 +64,6 @@ public function testJitterTime(): void

$backoffTime = $backoff->generate(4);

$this->assertNotEquals(4000, $backoffTime->toMilliseconds());
$this->assertNotEquals(4000, $backoffTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Config/ConfigBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testDefaults(): void
{
$configBuilder = new ConfigBuilder();

$this->assertEquals(60, $configBuilder->getCapTime()->toSeconds());
$this->assertEquals(60, $configBuilder->getCapTime()->asSeconds());
$this->assertEquals(INF, $configBuilder->getMaxAttempts());
$this->assertSame(false, $configBuilder->isJitterEnabled());
$this->assertInstanceOf(EqualJitter::class, $configBuilder->getJitter());
Expand Down
8 changes: 4 additions & 4 deletions tests/Duration/MicrosecondsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public function testMicroseconds(): void
{
$microseconds = new Microseconds(1 * 1000 * 1000);

$this->assertEquals(1 * 1000 * 1000 * 1000, $microseconds->toNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $microseconds->toMicroseconds());
$this->assertEquals(1 * 1000, $microseconds->toMilliseconds());
$this->assertEquals(1, $microseconds->toSeconds());
$this->assertEquals(1 * 1000 * 1000 * 1000, $microseconds->asNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $microseconds->asMicroseconds());
$this->assertEquals(1 * 1000, $microseconds->asMilliseconds());
$this->assertEquals(1, $microseconds->asSeconds());
}
}
8 changes: 4 additions & 4 deletions tests/Duration/MillisecondsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public function testMilliseconds(): void
{
$milliseconds = new Milliseconds(1 * 1000);

$this->assertEquals(1 * 1000 * 1000 * 1000, $milliseconds->toNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $milliseconds->toMicroseconds());
$this->assertEquals(1 * 1000, $milliseconds->toMilliseconds());
$this->assertEquals(1, $milliseconds->toSeconds());
$this->assertEquals(1 * 1000 * 1000 * 1000, $milliseconds->asNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $milliseconds->asMicroseconds());
$this->assertEquals(1 * 1000, $milliseconds->asMilliseconds());
$this->assertEquals(1, $milliseconds->asSeconds());
}
}
8 changes: 4 additions & 4 deletions tests/Duration/NanosecondsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public function testNanoseconds(): void
{
$nanoseconds = new Nanoseconds(1 * 1000 * 1000 * 1000);

$this->assertEquals(1 * 1000 * 1000 * 1000, $nanoseconds->toNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $nanoseconds->toMicroseconds());
$this->assertEquals(1 * 1000, $nanoseconds->toMilliseconds());
$this->assertEquals(1, $nanoseconds->toSeconds());
$this->assertEquals(1 * 1000 * 1000 * 1000, $nanoseconds->asNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $nanoseconds->asMicroseconds());
$this->assertEquals(1 * 1000, $nanoseconds->asMilliseconds());
$this->assertEquals(1, $nanoseconds->asSeconds());
}
}
8 changes: 4 additions & 4 deletions tests/Duration/SecondsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public function testSeconds(): void
{
$seconds = new Seconds(1);

$this->assertEquals(1 * 1000 * 1000 * 1000, $seconds->toNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $seconds->toMicroseconds());
$this->assertEquals(1 * 1000, $seconds->toMilliseconds());
$this->assertEquals(1, $seconds->toSeconds());
$this->assertEquals(1 * 1000 * 1000 * 1000, $seconds->asNanoseconds());
$this->assertEquals(1 * 1000 * 1000, $seconds->asMicroseconds());
$this->assertEquals(1 * 1000, $seconds->asMilliseconds());
$this->assertEquals(1, $seconds->asSeconds());
}
}
2 changes: 1 addition & 1 deletion tests/Factory/ConstantBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testConstant(): void

$backoffTime = $backoff->generate(4);

$this->assertEquals(1000, $backoffTime->toMilliseconds());
$this->assertEquals(1000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/ConstantEqualJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testConstantEqualJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(500, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(1000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(500, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(1000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/ConstantFullJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testConstantFullJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(0, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(1000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(0, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(1000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/DecorrelationJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testDecorrelationJitter(): void

$backoffTime = $backoff->generate(0);

$this->assertGreaterThanOrEqual(1000, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(3000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(1000, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(3000, $backoffTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Factory/ExponentialBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testExponential(): void

$backoffTime = $backoff->generate(4);

$this->assertEquals(16000, $backoffTime->toMilliseconds());
$this->assertEquals(16000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/ExponentialEqualJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testExponentialEqualJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(8000, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(16000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(8000, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(16000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/ExponentialFullJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testExponentialFullJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(0, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(16000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(0, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(16000, $backoffTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Factory/LinearBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testLinear(): void

$backoffTime = $backoff->generate(4);

$this->assertEquals(5000, $backoffTime->toMilliseconds());
$this->assertEquals(5000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/LinearEqualJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testLinearEqualJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(2500, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(5000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(2500, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(5000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Factory/LinearFullJitterBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testLinearFullJitter(): void

$backoffTime = $backoff->generate(4);

$this->assertGreaterThanOrEqual(0, $backoffTime->toMilliseconds());
$this->assertLessThanOrEqual(5000, $backoffTime->toMilliseconds());
$this->assertGreaterThanOrEqual(0, $backoffTime->asMilliseconds());
$this->assertLessThanOrEqual(5000, $backoffTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Jitter/EqualJitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testJitterTime(): void

$jitterTime = $equalJitter->getJitterTime(new Milliseconds(1000));

$this->assertGreaterThanOrEqual(500, $jitterTime->toMilliseconds());
$this->assertLessThanOrEqual(1000, $jitterTime->toMilliseconds());
$this->assertGreaterThanOrEqual(500, $jitterTime->asMilliseconds());
$this->assertLessThanOrEqual(1000, $jitterTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Jitter/FullJitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testJitterTime(): void

$jitterTime = $equalJitter->getJitterTime(new Milliseconds(1000));

$this->assertGreaterThanOrEqual(0, $jitterTime->toMilliseconds());
$this->assertLessThanOrEqual(1000, $jitterTime->toMilliseconds());
$this->assertGreaterThanOrEqual(0, $jitterTime->asMilliseconds());
$this->assertLessThanOrEqual(1000, $jitterTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Strategy/ConstantStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testWaitTime(): void

$waitTime = $strategy->getWaitTime(4);

$this->assertEquals(1000, $waitTime->toMilliseconds());
$this->assertEquals(1000, $waitTime->asMilliseconds());
}
}
4 changes: 2 additions & 2 deletions tests/Strategy/DecorrelationJitterStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testWaitTime(): void

$waitTime = $strategy->getWaitTime(0);

$this->assertGreaterThanOrEqual(1000, $waitTime->toMilliseconds());
$this->assertLessThanOrEqual(3000, $waitTime->toMilliseconds());
$this->assertGreaterThanOrEqual(1000, $waitTime->asMilliseconds());
$this->assertLessThanOrEqual(3000, $waitTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Strategy/ExponentialStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testWaitTime(): void

$waitTime = $strategy->getWaitTime(4);

$this->assertEquals(16000, $waitTime->toMilliseconds());
$this->assertEquals(16000, $waitTime->asMilliseconds());
}
}
2 changes: 1 addition & 1 deletion tests/Strategy/LinearStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testWaitTime(): void

$waitTime = $strategy->getWaitTime(4);

$this->assertEquals(5000, $waitTime->toMilliseconds());
$this->assertEquals(5000, $waitTime->asMilliseconds());
}
}

0 comments on commit 7c09600

Please sign in to comment.