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