Annotation of embedaddon/php/ext/standard/tests/class_object/is_a_variation_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test is_a() function : usage variations - wrong type for arg 1
! 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)
! 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: // Note: basic use cases in Zend/tests/is_a.phpt
! 13: echo "*** Testing is_a() : usage variations ***\n";
! 14:
! 15: // Initialise function arguments not being substituted (if any)
! 16: $class_name = 'stdClass';
! 17:
! 18: //get an unset variable
! 19: $unset_var = 10;
! 20: unset ($unset_var);
! 21:
! 22: //array of values to iterate over
! 23: $values = array(
! 24:
! 25: // int data
! 26: 0,
! 27: 1,
! 28: 12345,
! 29: -2345,
! 30:
! 31: // float data
! 32: 10.5,
! 33: -10.5,
! 34: 10.1234567e10,
! 35: 10.7654321E-10,
! 36: .5,
! 37:
! 38: // array data
! 39: array(),
! 40: array(0),
! 41: array(1),
! 42: array(1, 2),
! 43: array('color' => 'red', 'item' => 'pen'),
! 44:
! 45: // null data
! 46: NULL,
! 47: null,
! 48:
! 49: // boolean data
! 50: true,
! 51: false,
! 52: TRUE,
! 53: FALSE,
! 54:
! 55: // empty data
! 56: "",
! 57: '',
! 58:
! 59: // string data
! 60: "string",
! 61: 'String',
! 62:
! 63: // undefined data
! 64: $undefined_var,
! 65:
! 66: // unset data
! 67: $unset_var,
! 68: );
! 69:
! 70: // loop through each element of the array for object
! 71:
! 72: foreach($values as $value) {
! 73: echo "\nArg value $value \n";
! 74: var_dump( is_a($value, $class_name) );
! 75: };
! 76:
! 77: echo "Done";
! 78: ?>
! 79: --EXPECTF--
! 80: *** Testing is_a() : usage variations ***
! 81:
! 82: Notice: Undefined variable: undefined_var in %s on line 59
! 83:
! 84: Notice: Undefined variable: unset_var in %s on line 62
! 85:
! 86: Arg value 0
! 87: bool(false)
! 88:
! 89: Arg value 1
! 90: bool(false)
! 91:
! 92: Arg value 12345
! 93: bool(false)
! 94:
! 95: Arg value -2345
! 96: bool(false)
! 97:
! 98: Arg value 10.5
! 99: bool(false)
! 100:
! 101: Arg value -10.5
! 102: bool(false)
! 103:
! 104: Arg value 101234567000
! 105: bool(false)
! 106:
! 107: Arg value 1.07654321E-9
! 108: bool(false)
! 109:
! 110: Arg value 0.5
! 111: bool(false)
! 112:
! 113: Arg value Array
! 114: bool(false)
! 115:
! 116: Arg value Array
! 117: bool(false)
! 118:
! 119: Arg value Array
! 120: bool(false)
! 121:
! 122: Arg value Array
! 123: bool(false)
! 124:
! 125: Arg value Array
! 126: bool(false)
! 127:
! 128: Arg value
! 129: bool(false)
! 130:
! 131: Arg value
! 132: bool(false)
! 133:
! 134: Arg value 1
! 135: bool(false)
! 136:
! 137: Arg value
! 138: bool(false)
! 139:
! 140: Arg value 1
! 141: bool(false)
! 142:
! 143: Arg value
! 144: bool(false)
! 145:
! 146: Arg value
! 147: bool(false)
! 148:
! 149: Arg value
! 150: bool(false)
! 151:
! 152: Arg value string
! 153: bool(false)
! 154:
! 155: Arg value String
! 156: bool(false)
! 157:
! 158: Arg value
! 159: bool(false)
! 160:
! 161: Arg value
! 162: bool(false)
! 163: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>