1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 06:51:18 +02:00
Files
archived-php-src/ext/random/tests/03_randomizer/construct_twice.phpt
Tim Düsterhus f7d426cca6 Unify structure for ext/random's randomizer tests (#9410)
* Unify structure for ext/random's engine tests (2)

This makes adjustments that were missed in
2d6a883b3a.

* Add `engines.inc` for ext/random tests

* Unify structure for ext/random's randomizer tests
2022-08-31 19:22:39 +02:00

53 lines
1.3 KiB
PHP

--TEST--
Random: Randomizer: Calling __construct() fails due to readonly $engine property
--FILE--
<?php
use Random\Engine;
use Random\Engine\PcgOneseq128XslRr64;
use Random\Engine\Test\TestShaEngine;
use Random\Engine\Xoshiro256StarStar;
use Random\Randomizer;
require __DIR__ . "/../engines.inc";
try {
(new Randomizer())->__construct();
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
$randomizer = new Randomizer(new Xoshiro256StarStar());
$randomizer->__construct(new PcgOneseq128XslRr64());
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
$randomizer = new Randomizer(new TestShaEngine("1234"));
$randomizer->__construct(new TestShaEngine("1234"));
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
$randomizer = new Randomizer(new Xoshiro256StarStar());
$randomizer->__construct(new TestShaEngine("1234"));
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
var_dump($randomizer->engine::class);
die('success');
?>
--EXPECT--
Cannot modify readonly property Random\Randomizer::$engine
Cannot modify readonly property Random\Randomizer::$engine
Cannot modify readonly property Random\Randomizer::$engine
Cannot modify readonly property Random\Randomizer::$engine
string(32) "Random\Engine\Xoshiro256StarStar"
success