From 4c24ec5d8696827382e47440268eefea84436371 Mon Sep 17 00:00:00 2001 From: azjezz Date: Sat, 30 Mar 2024 04:40:12 +0000 Subject: [PATCH] chore(random-sequence): remove usage of deprecated API in tests Signed-off-by: azjezz --- .../MersenneTwisterPHPVariantSequenceTest.php | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/unit/RandomSequence/MersenneTwisterPHPVariantSequenceTest.php b/tests/unit/RandomSequence/MersenneTwisterPHPVariantSequenceTest.php index 39deff8a..c4410a02 100644 --- a/tests/unit/RandomSequence/MersenneTwisterPHPVariantSequenceTest.php +++ b/tests/unit/RandomSequence/MersenneTwisterPHPVariantSequenceTest.php @@ -6,38 +6,25 @@ use PHPUnit\Framework\TestCase; use Psl\RandomSequence\MersenneTwisterPHPVariantSequence; -use Psl\SecureRandom; - -use function mt_rand; -use function mt_srand; -use function time; - -use const MT_RAND_PHP; final class MersenneTwisterPHPVariantSequenceTest extends TestCase { /** * @dataProvider provideSeeds */ - public function testNext(int $seed): void + public function testNext(int $seed, array $expectations): void { - mt_srand($seed, MT_RAND_PHP); $sequence = new MersenneTwisterPHPVariantSequence($seed); - for ($i = 0; $i < 100; $i++) { - static::assertSame(mt_rand(), $sequence->next()); + for ($i = 0; $i < 5; $i++) { + static::assertSame($expectations[$i], $sequence->next()); } } public function provideSeeds(): iterable { - yield [2147483649]; - yield [45635]; - yield [5744]; - yield [456]; - yield [34]; - yield [5]; - yield [time()]; - yield [SecureRandom\int()]; + yield [2147483649, [90281504, 1278257534, 1994752345, 683161987, 992945549]]; + yield [45635, [899019714, 822361780, 1611332592, 632462060, 1431120852]]; + yield [5744, [1962086712, 1462838808, 1331836928, 446021369, 535020186]]; } }