1--TEST--
2Random: Randomizer: getBytes(): Returned bytes are consistently expanded
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Randomizer;
8
9final class TestEngine implements Engine
10{
11    private int $count = 0;
12
13    public function generate(): string
14    {
15        return match ($this->count++) {
16            0 => 'H',
17            1 => 'e',
18            2 => 'll',
19            3 => 'o',
20            4 => 'abcdefghijklmnopqrstuvwxyz',
21            5 => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
22            6 => 'success',
23            default => throw new \Exception('Unhandled'),
24        };
25    }
26}
27
28$randomizer = new Randomizer(new TestEngine());
29
30// 0-3: "Hello" - Insufficient bytes are concatenated.
31var_dump($randomizer->getBytes(5));
32
33// 4-5: "abcdefghABC" - Returned values are truncated to 64-bits for technical reasons, thus dropping i-z.
34var_dump($randomizer->getBytes(11));
35
36// 6: "success"
37var_dump($randomizer->getBytes(7));
38
39?>
40--EXPECT--
41string(5) "Hello"
42string(11) "abcdefghABC"
43string(7) "success"
44