Skip to content

Commit d42f3fa

Browse files
committed
chore(random-sequence): remove usage of deprecated API in tests
Signed-off-by: azjezz <[email protected]>
1 parent f161b4c commit d42f3fa

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

tests/unit/RandomSequence/MersenneTwisterPHPVariantSequenceTest.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,25 @@
66

77
use PHPUnit\Framework\TestCase;
88
use Psl\RandomSequence\MersenneTwisterPHPVariantSequence;
9-
use Psl\SecureRandom;
10-
11-
use function mt_rand;
12-
use function mt_srand;
13-
use function time;
14-
15-
use const MT_RAND_PHP;
169

1710
final class MersenneTwisterPHPVariantSequenceTest extends TestCase
1811
{
1912
/**
2013
* @dataProvider provideSeeds
2114
*/
22-
public function testNext(int $seed): void
15+
public function testNext(int $seed, array $expectations): void
2316
{
24-
mt_srand($seed, MT_RAND_PHP);
2517
$sequence = new MersenneTwisterPHPVariantSequence($seed);
2618

27-
for ($i = 0; $i < 100; $i++) {
28-
static::assertSame(mt_rand(), $sequence->next());
19+
for ($i = 0; $i < 5; $i++) {
20+
static::assertSame($expectations[$i], $sequence->next());
2921
}
3022
}
3123

3224
public function provideSeeds(): iterable
3325
{
34-
yield [2147483649];
35-
yield [45635];
36-
yield [5744];
37-
yield [456];
38-
yield [34];
39-
yield [5];
40-
yield [time()];
41-
yield [SecureRandom\int()];
26+
yield [2147483649, [90281504, 1278257534, 1994752345, 683161987, 992945549]];
27+
yield [45635, [899019714, 822361780, 1611332592, 632462060, 1431120852]];
28+
yield [5744, [1962086712, 1462838808, 1331836928, 446021369, 535020186]];
4229
}
4330
}

0 commit comments

Comments
 (0)