Annotation of embedaddon/php/ext/standard/tests/general_functions/escapeshellarg_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test 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: 
                     15: echo "*** Testing escapeshellarg() : error conditions ***\n";
                     16: 
                     17: 
                     18: echo "\n-- Testing escapeshellarg() function with no arguments --\n";
                     19: var_dump( escapeshellarg() );
                     20: 
                     21: echo "\n-- Testing escapeshellarg() function with more than expected no. of arguments --\n";
                     22: $arg = "Mr O'Neil";
                     23: $extra_arg = 10;
                     24: var_dump( escapeshellarg($arg, $extra_arg) );
                     25: 
                     26: echo "\n-- Testing escapeshellarg() function with a object supplied for argument --\n";
                     27: 
                     28: class classA
                     29: {
                     30: }
                     31: 
                     32: $arg = new classA();
                     33: var_dump( escapeshellarg($arg));
                     34: 
                     35: echo "\n-- Testing escapeshellarg() function with a resource supplied for argument --\n";
                     36: $fp = fopen(__FILE__, "r");
                     37: var_dump( escapeshellarg($fp));
                     38: fclose($fp);
                     39: 
                     40: echo "\n-- Testing escapeshellarg() function with a array supplied for argument --\n";
                     41: $arg = array(1,2,3); 
                     42: var_dump( escapeshellarg($arg));
                     43: 
                     44: ?>
                     45: ===Done===
                     46: --EXPECTF--
                     47: *** Testing escapeshellarg() : error conditions ***
                     48: 
                     49: -- Testing escapeshellarg() function with no arguments --
                     50: 
                     51: Warning: escapeshellarg() expects exactly 1 parameter, 0 given in %s on line %d
                     52: NULL
                     53: 
                     54: -- Testing escapeshellarg() function with more than expected no. of arguments --
                     55: 
                     56: Warning: escapeshellarg() expects exactly 1 parameter, 2 given in %s on line %d
                     57: NULL
                     58: 
                     59: -- Testing escapeshellarg() function with a object supplied for argument --
                     60: 
                     61: Warning: escapeshellarg() expects parameter 1 to be string, object given in %s on line %d
                     62: NULL
                     63: 
                     64: -- Testing escapeshellarg() function with a resource supplied for argument --
                     65: 
                     66: Warning: escapeshellarg() expects parameter 1 to be string, resource given in %s on line %d
                     67: NULL
                     68: 
                     69: -- Testing escapeshellarg() function with a array supplied for argument --
                     70: 
                     71: Warning: escapeshellarg() expects parameter 1 to be string, array given in %s on line %d
                     72: NULL
                     73: ===Done===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>