22
33namespace Tempest \Cryptography \Tests \Signing ;
44
5+ use PHPUnit \Framework \ExpectationFailedException ;
56use PHPUnit \Framework \TestCase ;
67use Tempest \Clock \MockClock ;
78use Tempest \Cryptography \Signing \Exceptions \SigningKeyWasInvalid ;
89use Tempest \Cryptography \Signing \SigningAlgorithm ;
910use Tempest \Cryptography \Signing \SigningConfig ;
1011use Tempest \Cryptography \Tests \CreatesSigner ;
12+ use Tempest \Cryptography \Tests \HasMoreIntegerAssertions ;
1113use Tempest \DateTime \Duration ;
1214
1315final class SignerTest extends TestCase
1416{
1517 use CreatesSigner;
18+ use HasMoreIntegerAssertions;
1619
1720 public function test_good_signature (): void
1821 {
@@ -163,8 +166,7 @@ public function test_time_protection(): void
163166 $ this ->assertTrue ($ signer ->verify ($ data , $ signature ));
164167 $ elapsed = microtime (true ) - $ start ;
165168
166- $ this ->assertGreaterThanOrEqual (0.29 , $ elapsed );
167- $ this ->assertLessThanOrEqual (0.311 , $ elapsed );
169+ $ this ->assertEqualsToMoreOrLess (0.3 , $ elapsed , margin: 0.015 );
168170 }
169171
170172 public function test_time_protection_with_mock_clock (): void
@@ -182,7 +184,6 @@ public function test_time_protection_with_mock_clock(): void
182184 $ this ->assertTrue ($ signer ->verify ($ data , $ signature ));
183185 $ elapsed = $ clock ->timestamp ()->getMilliseconds () - $ ms ;
184186
185- $ this ->assertLessThanOrEqual (1_001 , $ elapsed );
186- $ this ->assertGreaterThanOrEqual (999 , $ elapsed );
187+ $ this ->assertEqualsToMoreOrLess (1000 , $ elapsed , margin: 10 );
187188 }
188189}
0 commit comments