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$length = getenv("SKIP_SLOW_TESTS") ? 1_000 : 5_000; 24 25foreach ($engines as $engine) { 26 echo $engine::class, PHP_EOL; 27 28 $randomizer = new Randomizer($engine); 29 30 // This test is slow, test all numbers smaller than 50 and then in steps of 677 (which is prime). 31 for ($i = 1; $i < $length; $i += ($i < 50 ? 1 : 677)) { 32 $array = range(1, $i); 33 34 $result = $randomizer->shuffleArray($array); 35 36 sort($result); 37 38 if ($result !== $array) { 39 die("failure: not a permutation at {$i}"); 40 } 41 } 42} 43 44die('success'); 45 46?> 47--EXPECTF-- 48Deprecated: Constant MT_RAND_PHP is deprecated in %s on line %d 49 50Deprecated: The MT_RAND_PHP variant of Mt19937 is deprecated in %s on line %d 51Random\Engine\Mt19937 52Random\Engine\Mt19937 53Random\Engine\PcgOneseq128XslRr64 54Random\Engine\Xoshiro256StarStar 55Random\Engine\Secure 56Random\Engine\Test\TestShaEngine 57success 58