1--TEST--
2Test str_shuffle() function : basic functionality
3--FILE--
4<?php
5/*
6 * Testing str_shuffle() : basic functionality
7*/
8
9echo "*** Testing str_shuffle() : basic functionality ***\n";
10
11// Initialize all required variables
12$str = 'This testcase tests the str_shuffle() function.';
13var_dump(str_shuffle($str));
14
15
16// For a given i/p string ensure that all combinations are
17// generated given a reasonable sample of calls
18$a = array();
19$trys = 1000;
20$ip = 'abcd';
21$len_ip = strlen($ip);
22
23for ($i = 0; $i < $trys; $i++) {
24    $op = str_shuffle($ip);
25
26    if (!is_string($op) || strlen($op) != $len_ip) {
27        echo "TEST FAILED\n";
28    }
29
30    // Combination already hit ?
31    if (empty($a[$op])) {
32        // No first time init
33        $a[$op] = 0;
34    }
35
36    // Increment count for this combination
37    $a[$op]++;
38}
39
40$combinations = count($a);
41
42if ($combinations != 24) {
43    echo "TEST FAILED.. Only $combinations out of a possible 24 combinations used\n";
44} else {
45    echo "TEST PASSED\n";
46}
47
48?>
49--EXPECTF--
50*** Testing str_shuffle() : basic functionality ***
51string(47) "%s"
52TEST PASSED
53