Annotation of embedaddon/php/ext/standard/tests/class_object/is_subclass_of_error_001.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test is_subclass_of() function : wrong number of args 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto bool is_subclass_of(object object, string class_name)
                      6:  * Description: Returns true if the object has this class as one of its parents 
                      7:  * Source code: Zend/zend_builtin_functions.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: echo "*** Testing is_subclass_of() : error conditions ***\n";
                     12: 
                     13: 
                     14: //Test is_subclass_of with one more than the expected number of arguments
                     15: echo "\n-- Testing is_subclass_of() function with more than expected no. of arguments --\n";
                     16: $object = new stdclass();
                     17: $class_name = 'string_val';
                     18: $allow_string = false;
                     19: $extra_arg = 10;
                     20: var_dump( is_subclass_of($object, $class_name, $allow_string, $extra_arg) );
                     21: 
                     22: //Test is_subclass_of with invalid last argument
                     23: echo "\n-- Testing is_subclass_of() function with more than typo style invalid 3rd argument --\n";
                     24: var_dump( is_subclass_of($object, $class_name, $class_name) );
                     25: 
                     26: 
                     27: //Test is_subclass_of with invalid last argument
                     28: echo "\n-- Testing is_subclass_of() function with more than invalid 3rd argument --\n";
                     29: var_dump( is_subclass_of($object, $class_name, $object) );
                     30: 
                     31: // Testing is_subclass_of with one less than the expected number of arguments
                     32: echo "\n-- Testing is_subclass_of() function with less than expected no. of arguments --\n";
                     33: $object = new stdclass();
                     34: var_dump( is_subclass_of($object) );
                     35: 
                     36: echo "Done";
                     37: ?>
                     38: --EXPECTF--
                     39: *** Testing is_subclass_of() : error conditions ***
                     40: 
                     41: -- Testing is_subclass_of() function with more than expected no. of arguments --
                     42: 
                     43: Warning: is_subclass_of() expects at most 3 parameters, 4 given in %s on line 17
                     44: NULL
                     45: 
                     46: -- Testing is_subclass_of() function with more than typo style invalid 3rd argument --
                     47: bool(false)
                     48: 
                     49: -- Testing is_subclass_of() function with more than invalid 3rd argument --
                     50: 
                     51: Warning: is_subclass_of() expects parameter 3 to be boolean, object given in %s on line 26
                     52: NULL
                     53: 
                     54: -- Testing is_subclass_of() function with less than expected no. of arguments --
                     55: 
                     56: Warning: is_subclass_of() expects at least 2 parameters, 1 given in %s on line 31
                     57: NULL
                     58: Done

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