1--TEST-- 2Random: Randomizer: shuffleArray(): Basic functionality 3--FILE-- 4<?php 5 6use Random\Engine; 7use Random\Engine\Mt19937; 8use Random\Engine\PcgOneseq128XslRr64; 9use Random\Engine\Secure; 10use Random\Engine\Test\TestShaEngine; 11use Random\Engine\Xoshiro256StarStar; 12use Random\Randomizer; 13 14require __DIR__ . "/../../engines.inc"; 15 16$engines = []; 17$engines[] = new Mt19937(null, MT_RAND_MT19937); 18$engines[] = new Mt19937(null, MT_RAND_PHP); 19$engines[] = new PcgOneseq128XslRr64(); 20$engines[] = new Xoshiro256StarStar(); 21$engines[] = new Secure(); 22$engines[] = new TestShaEngine(); 23 24foreach ($engines as $engine) { 25 echo $engine::class, PHP_EOL; 26 27 $randomizer = new Randomizer($engine); 28 29 // This test is slow, test all numbers smaller than 50 and then in steps of 677 (which is prime). 30 for ($i = 1; $i < 5_000; $i += ($i < 50 ? 1 : 677)) { 31 $array = range(1, $i); 32 33 $result = $randomizer->shuffleArray($array); 34 35 sort($result); 36 37 if ($result !== $array) { 38 die("failure: not a permutation at {$i}"); 39 } 40 } 41} 42 43die('success'); 44 45?> 46--EXPECTF-- 47Deprecated: Constant MT_RAND_PHP is deprecated in %s on line %d 48 49Deprecated: The MT_RAND_PHP variant of Mt19937 is deprecated in %s on line %d 50Random\Engine\Mt19937 51Random\Engine\Mt19937 52Random\Engine\PcgOneseq128XslRr64 53Random\Engine\Xoshiro256StarStar 54Random\Engine\Secure 55Random\Engine\Test\TestShaEngine 56success 57