1--TEST--
2Test escapeshellarg() function : error conditions -  wrong numbers of parameters
3--FILE--
4<?php
5
6/* Prototype  : string escapeshellarg  ( string $arg  )
7 * Description:  Escape a string to be used as a shell argument.
8 * Source code: ext/standard/exec.c
9 */
10
11/*
12 * Pass an incorrect number of arguments to escapeshellarg() to test behaviour
13 */
14
15echo "*** Testing escapeshellarg() : error conditions ***\n";
16
17
18echo "\n-- Testing escapeshellarg() function with no arguments --\n";
19var_dump( escapeshellarg() );
20
21echo "\n-- Testing escapeshellarg() function with more than expected no. of arguments --\n";
22$arg = "Mr O'Neil";
23$extra_arg = 10;
24var_dump( escapeshellarg($arg, $extra_arg) );
25
26echo "\n-- Testing escapeshellarg() function with a object supplied for argument --\n";
27
28class classA
29{
30}
31
32$arg = new classA();
33var_dump( escapeshellarg($arg));
34
35echo "\n-- Testing escapeshellarg() function with a resource supplied for argument --\n";
36$fp = fopen(__FILE__, "r");
37var_dump( escapeshellarg($fp));
38fclose($fp);
39
40echo "\n-- Testing escapeshellarg() function with a array supplied for argument --\n";
41$arg = array(1,2,3);
42var_dump( escapeshellarg($arg));
43
44?>
45===Done===
46--EXPECTF--
47*** Testing escapeshellarg() : error conditions ***
48
49-- Testing escapeshellarg() function with no arguments --
50
51Warning: escapeshellarg() expects exactly 1 parameter, 0 given in %s on line %d
52NULL
53
54-- Testing escapeshellarg() function with more than expected no. of arguments --
55
56Warning: escapeshellarg() expects exactly 1 parameter, 2 given in %s on line %d
57NULL
58
59-- Testing escapeshellarg() function with a object supplied for argument --
60
61Warning: escapeshellarg() expects parameter 1 to be string, object given in %s on line %d
62NULL
63
64-- Testing escapeshellarg() function with a resource supplied for argument --
65
66Warning: escapeshellarg() expects parameter 1 to be string, resource given in %s on line %d
67NULL
68
69-- Testing escapeshellarg() function with a array supplied for argument --
70
71Warning: escapeshellarg() expects parameter 1 to be string, array given in %s on line %d
72NULL
73===Done===
74