Annotation of embedaddon/php/ext/standard/tests/array/array_multisort_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_multisort() function : usage variation
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
! 6: * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
! 7: * Source code: ext/standard/array.c
! 8: * Alias to functions:
! 9: */
! 10:
! 11: echo "*** Testing array_multisort() : usage variation ***\n";
! 12:
! 13: // Define error handler
! 14: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
! 15: if (error_reporting() != 0) {
! 16: // report non-silenced errors
! 17: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
! 18: }
! 19: }
! 20: set_error_handler('test_error_handler');
! 21:
! 22: $ar2 = array(1, 2);
! 23:
! 24: //get an unset variable
! 25: $unset_var = 10;
! 26: unset ($unset_var);
! 27:
! 28: // define some classes
! 29: class classWithToString
! 30: {
! 31: public function __toString() {
! 32: return "Class A object";
! 33: }
! 34: }
! 35:
! 36: class classWithoutToString
! 37: {
! 38: }
! 39:
! 40: // heredoc string
! 41: $heredoc = <<<EOT
! 42: hello world
! 43: EOT;
! 44:
! 45: // add arrays
! 46: $index_array = array (1, 2, 3);
! 47: $assoc_array = array ('one' => 1, 'two' => 2);
! 48:
! 49: //array of values to iterate over
! 50: $inputs = array(
! 51:
! 52: // int data
! 53: 'int 0' => 0,
! 54: 'int 1' => 1,
! 55: 'int 12345' => 12345,
! 56: 'int -12345' => -2345,
! 57:
! 58: // float data
! 59: 'float 10.5' => 10.5,
! 60: 'float -10.5' => -10.5,
! 61: 'float 12.3456789000e10' => 12.3456789000e10,
! 62: 'float -12.3456789000e10' => -12.3456789000e10,
! 63: 'float .5' => .5,
! 64:
! 65: // null data
! 66: 'uppercase NULL' => NULL,
! 67: 'lowercase null' => null,
! 68:
! 69: // boolean data
! 70: 'lowercase true' => true,
! 71: 'lowercase false' =>false,
! 72: 'uppercase TRUE' =>TRUE,
! 73: 'uppercase FALSE' =>FALSE,
! 74:
! 75: // empty data
! 76: 'empty string DQ' => "",
! 77: 'empty string SQ' => '',
! 78:
! 79: // string data
! 80: 'string DQ' => "string",
! 81: 'string SQ' => 'string',
! 82: 'mixed case string' => "sTrInG",
! 83: 'heredoc' => $heredoc,
! 84:
! 85: // object data
! 86: 'instance of classWithToString' => new classWithToString(),
! 87: 'instance of classWithoutToString' => new classWithoutToString(),
! 88:
! 89: // undefined data
! 90: 'undefined var' => @$undefined_var,
! 91:
! 92: // unset data
! 93: 'unset var' => @$unset_var,
! 94: );
! 95:
! 96: // loop through each element of the array for ar1
! 97:
! 98: foreach($inputs as $key =>$value) {
! 99: echo "\n--$key--\n";
! 100: var_dump( array_multisort($value));
! 101: };
! 102:
! 103: ?>
! 104: ===DONE===
! 105: --EXPECTF--
! 106: *** Testing array_multisort() : usage variation ***
! 107:
! 108: --int 0--
! 109: Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
! 110: bool(false)
! 111:
! 112: --int 1--
! 113: Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
! 114: bool(false)
! 115:
! 116: --int 12345--
! 117: Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
! 118: bool(false)
! 119:
! 120: --int -12345--
! 121: Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
! 122: bool(false)
! 123:
! 124: --float 10.5--
! 125: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 126: bool(false)
! 127:
! 128: --float -10.5--
! 129: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 130: bool(false)
! 131:
! 132: --float 12.3456789000e10--
! 133: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 134: bool(false)
! 135:
! 136: --float -12.3456789000e10--
! 137: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 138: bool(false)
! 139:
! 140: --float .5--
! 141: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 142: bool(false)
! 143:
! 144: --uppercase NULL--
! 145: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 146: bool(false)
! 147:
! 148: --lowercase null--
! 149: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 150: bool(false)
! 151:
! 152: --lowercase true--
! 153: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 154: bool(false)
! 155:
! 156: --lowercase false--
! 157: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 158: bool(false)
! 159:
! 160: --uppercase TRUE--
! 161: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 162: bool(false)
! 163:
! 164: --uppercase FALSE--
! 165: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 166: bool(false)
! 167:
! 168: --empty string DQ--
! 169: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 170: bool(false)
! 171:
! 172: --empty string SQ--
! 173: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 174: bool(false)
! 175:
! 176: --string DQ--
! 177: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 178: bool(false)
! 179:
! 180: --string SQ--
! 181: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 182: bool(false)
! 183:
! 184: --mixed case string--
! 185: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 186: bool(false)
! 187:
! 188: --heredoc--
! 189: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 190: bool(false)
! 191:
! 192: --instance of classWithToString--
! 193: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 194: bool(false)
! 195:
! 196: --instance of classWithoutToString--
! 197: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 198: bool(false)
! 199:
! 200: --undefined var--
! 201: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 202: bool(false)
! 203:
! 204: --unset var--
! 205: Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
! 206: bool(false)
! 207: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>