1--TEST-- 2Random: Randomizer: pickArrayKeys(): Parameters are correctly validated 3--FILE-- 4<?php 5 6use Random\Randomizer; 7 8function randomizer(): Randomizer 9{ 10 return new Randomizer(); 11} 12 13try { 14 var_dump(randomizer()->pickArrayKeys("foo", 2)); 15} catch (TypeError $e) { 16 echo $e->getMessage(), PHP_EOL; 17} 18 19try { 20 var_dump(randomizer()->pickArrayKeys([], 0)); 21} catch (ValueError $e) { 22 echo $e->getMessage(), PHP_EOL; 23} 24 25try { 26 var_dump(randomizer()->pickArrayKeys(range(1, 3), 0)); 27} catch (ValueError $e) { 28 echo $e->getMessage(), PHP_EOL; 29} 30 31try { 32 var_dump(randomizer()->pickArrayKeys(range(1, 3), -1)); 33} catch (ValueError $e) { 34 echo $e->getMessage(), PHP_EOL; 35} 36 37try { 38 var_dump(randomizer()->pickArrayKeys(range(1, 3), 10)); 39} catch (ValueError $e) { 40 echo $e->getMessage(), PHP_EOL; 41} 42 43?> 44--EXPECTF-- 45Random\Randomizer::pickArrayKeys(): Argument #1 ($array) must be of type array, string given 46Random\Randomizer::pickArrayKeys(): Argument #1 ($array) cannot be empty 47Random\Randomizer::pickArrayKeys(): Argument #2 ($num) must be between 1 and the number of elements in argument #1 ($array) 48Random\Randomizer::pickArrayKeys(): Argument #2 ($num) must be between 1 and the number of elements in argument #1 ($array) 49Random\Randomizer::pickArrayKeys(): Argument #2 ($num) must be between 1 and the number of elements in argument #1 ($array) 50