1--TEST-- 2Random: Engine: PcgOneseq128XslRr64: The seed parameter must work as expected 3--FILE-- 4<?php declare(strict_types = 1); 5 6use Random\Engine\PcgOneseq128XslRr64; 7 8echo "Random integer seed", PHP_EOL; 9$engine = new PcgOneseq128XslRr64(random_int(PHP_INT_MIN, PHP_INT_MAX)); 10echo PHP_EOL, PHP_EOL; 11 12echo "Random string seed", PHP_EOL; 13$engine = new PcgOneseq128XslRr64(random_bytes(16)); 14echo PHP_EOL, PHP_EOL; 15 16echo "Invalid data type", PHP_EOL; 17try { 18 $engine = new PcgOneseq128XslRr64(1.0); 19} catch (TypeError $e) { 20 echo $e->getMessage(), PHP_EOL; 21} 22echo PHP_EOL, PHP_EOL; 23 24echo "Invalid string seed length", PHP_EOL; 25try { 26 $engine = new PcgOneseq128XslRr64('foobar'); 27} catch (ValueError $e) { 28 echo $e->getMessage(), PHP_EOL; 29} 30echo PHP_EOL, PHP_EOL; 31 32echo "Valid string seed", PHP_EOL; 33$engine = new PcgOneseq128XslRr64(str_repeat("\x01\x02\x03\x04\x05\x06\x07\x08", 2)); 34 35var_dump($engine); 36 37for ($i = 0; $i < 1000; $i++) { 38 $engine->generate(); 39} 40 41var_dump(bin2hex($engine->generate())); 42 43?> 44--EXPECT-- 45Random integer seed 46 47 48Random string seed 49 50 51Invalid data type 52Random\Engine\PcgOneseq128XslRr64::__construct(): Argument #1 ($seed) must be of type string|int|null, float given 53 54 55Invalid string seed length 56Random\Engine\PcgOneseq128XslRr64::__construct(): Argument #1 ($seed) must be a 16 byte (128 bit) string 57 58 59Valid string seed 60object(Random\Engine\PcgOneseq128XslRr64)#3 (1) { 61 ["__states"]=> 62 array(2) { 63 [0]=> 64 string(16) "7afbdfd5830d8250" 65 [1]=> 66 string(16) "dfc50b6959b3bafc" 67 } 68} 69string(16) "c42016cd9005ef2e" 70