2
2
3
3
namespace Tempest \Cryptography \Tests \Signing ;
4
4
5
+ use PHPUnit \Framework \ExpectationFailedException ;
5
6
use PHPUnit \Framework \TestCase ;
6
7
use Tempest \Clock \MockClock ;
7
8
use Tempest \Cryptography \Signing \Exceptions \SigningKeyWasInvalid ;
8
9
use Tempest \Cryptography \Signing \SigningAlgorithm ;
9
10
use Tempest \Cryptography \Signing \SigningConfig ;
10
11
use Tempest \Cryptography \Tests \CreatesSigner ;
12
+ use Tempest \Cryptography \Tests \HasMoreIntegerAssertions ;
11
13
use Tempest \DateTime \Duration ;
12
14
13
15
final class SignerTest extends TestCase
14
16
{
15
17
use CreatesSigner;
18
+ use HasMoreIntegerAssertions;
16
19
17
20
public function test_good_signature (): void
18
21
{
@@ -163,8 +166,7 @@ public function test_time_protection(): void
163
166
$ this ->assertTrue ($ signer ->verify ($ data , $ signature ));
164
167
$ elapsed = microtime (true ) - $ start ;
165
168
166
- $ this ->assertGreaterThanOrEqual (0.29 , $ elapsed );
167
- $ this ->assertLessThanOrEqual (0.311 , $ elapsed );
169
+ $ this ->assertEqualsToMoreOrLess (0.3 , $ elapsed , margin: 0.015 );
168
170
}
169
171
170
172
public function test_time_protection_with_mock_clock (): void
@@ -182,7 +184,6 @@ public function test_time_protection_with_mock_clock(): void
182
184
$ this ->assertTrue ($ signer ->verify ($ data , $ signature ));
183
185
$ elapsed = $ clock ->timestamp ()->getMilliseconds () - $ ms ;
184
186
185
- $ this ->assertLessThanOrEqual (1_001 , $ elapsed );
186
- $ this ->assertGreaterThanOrEqual (999 , $ elapsed );
187
+ $ this ->assertEqualsToMoreOrLess (1000 , $ elapsed , margin: 10 );
187
188
}
188
189
}
0 commit comments