1--TEST--
2Random: Randomizer: Calling __construct() fails due to readonly $engine property
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Engine\PcgOneseq128XslRr64;
8use Random\Engine\Test\TestShaEngine;
9use Random\Engine\Xoshiro256StarStar;
10use Random\Randomizer;
11
12require __DIR__ . "/../engines.inc";
13
14try {
15    (new Randomizer())->__construct();
16} catch (Error $e) {
17    echo $e->getMessage(), PHP_EOL;
18}
19
20try {
21    $randomizer = new Randomizer(new Xoshiro256StarStar());
22    $randomizer->__construct(new PcgOneseq128XslRr64());
23} catch (Error $e) {
24    echo $e->getMessage(), PHP_EOL;
25}
26
27try {
28    $randomizer = new Randomizer(new TestShaEngine("1234"));
29    $randomizer->__construct(new TestShaEngine("1234"));
30} catch (Error $e) {
31    echo $e->getMessage(), PHP_EOL;
32}
33
34try {
35    $randomizer = new Randomizer(new Xoshiro256StarStar());
36    $randomizer->__construct(new TestShaEngine("1234"));
37} catch (Error $e) {
38    echo $e->getMessage(), PHP_EOL;
39}
40
41var_dump($randomizer->engine::class);
42
43die('success');
44
45?>
46--EXPECT--
47Cannot modify readonly property Random\Randomizer::$engine
48Cannot modify readonly property Random\Randomizer::$engine
49Cannot modify readonly property Random\Randomizer::$engine
50Cannot modify readonly property Random\Randomizer::$engine
51string(32) "Random\Engine\Xoshiro256StarStar"
52success
53