Return to is_a_error_001.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / class_object |
1.1 misho 1: --TEST-- 2: Test is_a() function : error conditions - wrong number of args 3: --INI-- 4: error_reporting=E_ALL | E_STRICT | E_DEPRECATED 5: --FILE-- 6: <?php 7: /* Prototype : proto bool is_a(object object, string class_name, bool allow_string) 8: * Description: Returns true if the object is of this class or has this class as one of its parents 9: * Source code: Zend/zend_builtin_functions.c 10: * Alias to functions: 11: */ 12: 13: echo "*** Testing is_a() : error conditions ***\n"; 14: 15: //Test is_a with one more than the expected number of arguments 16: echo "\n-- Testing is_a() function with more than expected no. of arguments --\n"; 17: $object = new stdclass(); 18: $class_name = 'string_val'; 19: $allow_string = false; 20: $extra_arg = 10; 21: 22: var_dump( is_a($object, $class_name, $allow_string, $object) ); 23: 24: //Test is_a with one more than the expected number of arguments 25: echo "\n-- Testing is_a() function with non-boolean in last position --\n"; 26: var_dump( is_a($object, $class_name, $object) ); 27: 28: 29: // Testing is_a with one less than the expected number of arguments 30: echo "\n-- Testing is_a() function with less than expected no. of arguments --\n"; 31: $object = new stdclass(); 32: var_dump( is_a($object) ); 33: 34: echo "Done"; 35: ?> 36: --EXPECTF-- 37: 38: *** Testing is_a() : error conditions *** 39: 40: -- Testing is_a() function with more than expected no. of arguments -- 41: 42: Warning: is_a() expects at most 3 parameters, 4 given in %s on line 17 43: NULL 44: 45: -- Testing is_a() function with non-boolean in last position -- 46: 47: Warning: is_a() expects parameter 3 to be boolean, object given in %s on line 21 48: NULL 49: 50: -- Testing is_a() function with less than expected no. of arguments -- 51: 52: Warning: is_a() expects at least 2 parameters, 1 given in %s on line 27 53: NULL 54: Done