Annotation of embedaddon/php/ext/standard/tests/url/rawurlencode_variation_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test rawurlencode() function : usage variations - unexpected type for arg 1.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : proto string rawurlencode(string str)
! 6: * Description: URL-encodes string
! 7: * Source code: ext/standard/url.c
! 8: * Alias to functions:
! 9: */
! 10:
! 11: // NB: basic functionality tested in tests/strings/001.phpt
! 12:
! 13: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
! 14: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
! 15: }
! 16: set_error_handler('test_error_handler');
! 17:
! 18: echo "*** Testing rawurlencode() : usage variations ***\n";
! 19:
! 20: // Initialise function arguments not being substituted (if any)
! 21:
! 22: //get an unset variable
! 23: $unset_var = 10;
! 24: unset ($unset_var);
! 25:
! 26: //array of values to iterate over
! 27: $values = array(
! 28:
! 29: // int data
! 30: 0,
! 31: 1,
! 32: 12345,
! 33: -2345,
! 34:
! 35: // float data
! 36: 10.5,
! 37: -10.5,
! 38: 10.1234567e10,
! 39: 10.7654321E-10,
! 40: .5,
! 41:
! 42: // array data
! 43: array(),
! 44: array(0),
! 45: array(1),
! 46: array(1, 2),
! 47: array('color' => 'red', 'item' => 'pen'),
! 48:
! 49: // null data
! 50: NULL,
! 51: null,
! 52:
! 53: // boolean data
! 54: true,
! 55: false,
! 56: TRUE,
! 57: FALSE,
! 58:
! 59: // empty data
! 60: "",
! 61: '',
! 62:
! 63: // object data
! 64: new stdclass(),
! 65:
! 66: // undefined data
! 67: $undefined_var,
! 68:
! 69: // unset data
! 70: $unset_var,
! 71: );
! 72:
! 73: // loop through each element of the array for str
! 74:
! 75: foreach($values as $value) {
! 76: echo "\nArg value $value \n";
! 77: var_dump( rawurlencode($value) );
! 78: };
! 79:
! 80: echo "Done";
! 81: ?>
! 82: --EXPECTF--
! 83: *** Testing rawurlencode() : usage variations ***
! 84: Error: 8 - Undefined variable: undefined_var, %s(64)
! 85: Error: 8 - Undefined variable: unset_var, %s(67)
! 86:
! 87: Arg value 0
! 88: string(1) "0"
! 89:
! 90: Arg value 1
! 91: string(1) "1"
! 92:
! 93: Arg value 12345
! 94: string(5) "12345"
! 95:
! 96: Arg value -2345
! 97: string(5) "-2345"
! 98:
! 99: Arg value 10.5
! 100: string(4) "10.5"
! 101:
! 102: Arg value -10.5
! 103: string(5) "-10.5"
! 104:
! 105: Arg value 101234567000
! 106: string(12) "101234567000"
! 107:
! 108: Arg value 1.07654321E-9
! 109: string(13) "1.07654321E-9"
! 110:
! 111: Arg value 0.5
! 112: string(3) "0.5"
! 113:
! 114: Arg value Array
! 115: Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
! 116: NULL
! 117:
! 118: Arg value Array
! 119: Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
! 120: NULL
! 121:
! 122: Arg value Array
! 123: Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
! 124: NULL
! 125:
! 126: Arg value Array
! 127: Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
! 128: NULL
! 129:
! 130: Arg value Array
! 131: Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
! 132: NULL
! 133:
! 134: Arg value
! 135: string(0) ""
! 136:
! 137: Arg value
! 138: string(0) ""
! 139:
! 140: Arg value 1
! 141: string(1) "1"
! 142:
! 143: Arg value
! 144: string(0) ""
! 145:
! 146: Arg value 1
! 147: string(1) "1"
! 148:
! 149: Arg value
! 150: string(0) ""
! 151:
! 152: Arg value
! 153: string(0) ""
! 154:
! 155: Arg value
! 156: string(0) ""
! 157: Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
! 158:
! 159: Arg value
! 160: Error: 2 - rawurlencode() expects parameter 1 to be string, object given, %s(74)
! 161: NULL
! 162:
! 163: Arg value
! 164: string(0) ""
! 165:
! 166: Arg value
! 167: string(0) ""
! 168: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>