1--TEST--
2Random: Randomizer: The Mt19937 engine and pickArrayKeys are consistent with array_rand()
3--FILE--
4<?php
5
6use Random\Engine\Mt19937;
7use Random\Randomizer;
8
9$map = ['foo' => 0, 'bar' => 1, 'baz' => 2];
10$list = range(1, 10);
11
12mt_srand(1234);
13
14$mapPickOneFunc = array_rand($map, 1);
15$mapPickTwoFunc = array_rand($map, 2);
16
17$listPickOneFunc = array_rand($list, 1);
18$listPickTwoFunc = array_rand($list, 2);
19
20$randomizer = new Randomizer(new Mt19937(1234));
21
22[$mapPickOneMethod] = $randomizer->pickArrayKeys($map, 1);
23$mapPickTwoMethod = $randomizer->pickArrayKeys($map, 2);
24
25[$listPickOneMethod] = $randomizer->pickArrayKeys($list, 1);
26$listPickTwoMethod = $randomizer->pickArrayKeys($list, 2);
27
28if ($mapPickOneFunc !== $mapPickOneMethod) {
29    var_dump($mapPickOneFunc, $mapPickOneMethod);
30
31    die('failure: mapPickOne');
32}
33
34if ($mapPickTwoFunc !== $mapPickTwoMethod) {
35    var_dump($mapPickTwoFunc, $mapPickTwoMethod);
36
37    die('failure: mapPickTwo');
38}
39
40if ($listPickOneFunc !== $listPickOneMethod) {
41    var_dump($listPickOneFunc, $listPickOneMethod);
42
43    die('failure: listPickOne');
44}
45
46if ($listPickTwoFunc !== $listPickTwoMethod) {
47    var_dump($listPickTwoFunc, $listPickOneMethod);
48
49    die('failure: listPickTwo');
50}
51
52die('success');
53
54?>
55--EXPECT--
56success
57