1--TEST--
2Random: Randomizer: getBytes(): 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// Using 10_000 is very slow.
24$iterations = getenv("SKIP_SLOW_TESTS") ? 100 : 1_000;
25
26foreach ($engines as $engine) {
27    echo $engine::class, PHP_EOL;
28
29    $randomizer = new Randomizer($engine);
30
31    for ($i = 1; $i < $iterations; $i++) {
32        if (\strlen($randomizer->getBytes($i)) !== $i) {
33            die("failure: incorrect string length at {$i}");
34        }
35    }
36}
37
38die('success');
39
40?>
41--EXPECTF--
42Deprecated: Constant MT_RAND_PHP is deprecated in %s on line %d
43
44Deprecated: The MT_RAND_PHP variant of Mt19937 is deprecated in %s on line %d
45Random\Engine\Mt19937
46Random\Engine\Mt19937
47Random\Engine\PcgOneseq128XslRr64
48Random\Engine\Xoshiro256StarStar
49Random\Engine\Secure
50Random\Engine\Test\TestShaEngine
51success
52