1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 07:28:09 +02:00
Files
archived-php-src/ext/random/tests/03_randomizer/engine_unsafe_throws.phpt
T
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

29 lines
576 B
PHP

--TEST--
Random: Randomizer: Engines throwing an exception are gracefully handled
--FILE--
<?php
use Random\Engine;
use Random\Randomizer;
final class ThrowingEngine implements Engine
{
public function generate(): string
{
throw new Exception('Error');
}
}
$randomizer = new Randomizer(new ThrowingEngine());
var_dump($randomizer->getBytes(1));
?>
--EXPECTF--
Fatal error: Uncaught Exception: Error in %s:%d
Stack trace:
#0 [internal function]: ThrowingEngine->generate()
#1 %s(%d): Random\Randomizer->getBytes(1)
#2 {main}
thrown in %s on line %d