1--TEST--
2Test getrusage() function : error conditions - incorrect number of args
3--SKIPIF--
4<?php if (!function_exists("getrusage")) print "skip"; ?>
5--FILE--
6<?php
7/* Prototype  :  array getrusage  ([ int $who  ] )
8 * Description: Gets the current resource usages
9 * Source code: ext/standard/microtime.c
10 * Alias to functions:
11 */
12
13/*
14 * Pass an incorrect number of arguments to getrusage() to test behaviour
15 */
16
17echo "*** Testing getrusage() : error conditions ***\n";
18
19echo "\n-- Testing getrusage() function with more than expected no. of arguments --\n";
20$extra_arg = 10;
21$dat = getrusage(1, $extra_arg);
22
23echo "\n-- Testing getrusage() function with invalid argument - non-numeric STRING--\n";
24$string_arg = "foo";
25$dat = getrusage($string_arg);
26
27echo "\n-- Testing getrusage() function with invalid argument - ARRAY--\n";
28$array_arg = array(1,2,3);
29$dat = getrusage($array_arg);
30
31echo "\n-- Testing getrusage() function with invalid argument - OBJECT --\n";
32class classA
33{
34  function __toString() {
35    return "ClassAObject";
36  }
37}
38$obj_arg = new classA();
39$dat = getrusage($obj_arg);
40
41echo "\n-- Testing getrusage() function with invalid argument - RESOURCE --\n";
42$file_handle=fopen(__FILE__, "r");
43$dat = getrusage($file_handle);
44fclose($file_handle);
45
46?>
47===DONE===
48--EXPECTF--
49*** Testing getrusage() : error conditions ***
50
51-- Testing getrusage() function with more than expected no. of arguments --
52
53Warning: getrusage() expects at most 1 parameter, 2 given in %s on line %d
54
55-- Testing getrusage() function with invalid argument - non-numeric STRING--
56
57Warning: getrusage() expects parameter 1 to be integer, string given in %s on line %d
58
59-- Testing getrusage() function with invalid argument - ARRAY--
60
61Warning: getrusage() expects parameter 1 to be integer, array given in %s on line %d
62
63-- Testing getrusage() function with invalid argument - OBJECT --
64
65Warning: getrusage() expects parameter 1 to be integer, object given in %s on line %d
66
67-- Testing getrusage() function with invalid argument - RESOURCE --
68
69Warning: getrusage() expects parameter 1 to be integer, resource given in %s on line %d
70===DONE===
71