Annotation of embedaddon/php/ext/date/tests/date_sunrise_variation4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test date_sunrise() function : usage variation - Passing unexpected values to fourth argument longitude.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
! 6: * Description: Returns time of sunrise for a given day and location
! 7: * Source code: ext/date/php_date.c
! 8: * Alias to functions:
! 9: */
! 10:
! 11: echo "*** Testing date_sunrise() : usage variation ***\n";
! 12:
! 13: //Initialise the variables
! 14: date_default_timezone_set("Asia/Calcutta");
! 15: $time = mktime(8, 8, 8, 8, 8, 2008);
! 16: $latitude = 38.4;
! 17: $zenith = 90;
! 18: $gmt_offset = 0;
! 19:
! 20: //get an unset variable
! 21: $unset_var = 10;
! 22: unset ($unset_var);
! 23:
! 24: // define some classes
! 25: class classWithToString
! 26: {
! 27: public function __toString() {
! 28: return "Class A object";
! 29: }
! 30: }
! 31:
! 32: class classWithoutToString
! 33: {
! 34: }
! 35:
! 36: // heredoc string
! 37: $heredoc = <<<EOT
! 38: hello world
! 39: EOT;
! 40:
! 41: // add arrays
! 42: $index_array = array (1, 2, 3);
! 43: $assoc_array = array ('one' => 1, 'two' => 2);
! 44:
! 45: //array of values to iterate over
! 46: $inputs = array(
! 47:
! 48: // int data
! 49: 'int 0' => 0,
! 50: 'int 1' => 1,
! 51: 'int 12345' => 12345,
! 52: 'int -12345' => -12345,
! 53:
! 54: // array data
! 55: 'empty array' => array(),
! 56: 'int indexed array' => $index_array,
! 57: 'associative array' => $assoc_array,
! 58: 'nested arrays' => array('foo', $index_array, $assoc_array),
! 59:
! 60: // null data
! 61: 'uppercase NULL' => NULL,
! 62: 'lowercase null' => null,
! 63:
! 64: // boolean data
! 65: 'lowercase true' => true,
! 66: 'lowercase false' =>false,
! 67: 'uppercase TRUE' =>TRUE,
! 68: 'uppercase FALSE' =>FALSE,
! 69:
! 70: // empty data
! 71: 'empty string DQ' => "",
! 72: 'empty string SQ' => '',
! 73:
! 74: // string data
! 75: 'string DQ' => "string",
! 76: 'string SQ' => 'string',
! 77: 'mixed case string' => "sTrInG",
! 78: 'heredoc' => $heredoc,
! 79:
! 80: // object data
! 81: 'instance of classWithToString' => new classWithToString(),
! 82: 'instance of classWithoutToString' => new classWithoutToString(),
! 83:
! 84: // undefined data
! 85: 'undefined var' => @$undefined_var,
! 86:
! 87: // unset data
! 88: 'unset var' => @$unset_var,
! 89: );
! 90:
! 91: // loop through each element of the array for longitude
! 92:
! 93: foreach($inputs as $key =>$value) {
! 94: echo "\n--$key--\n";
! 95: var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $value, $zenith, $gmt_offset) );
! 96: var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $value, $zenith, $gmt_offset) );
! 97: var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $value, $zenith, $gmt_offset) );
! 98: };
! 99:
! 100: ?>
! 101: ===DONE===
! 102: --EXPECTF--
! 103: *** Testing date_sunrise() : usage variation ***
! 104:
! 105: --int 0--
! 106: string(5) "05:12"
! 107: float(5.200%d)
! 108: int(1218172321)
! 109:
! 110: --int 1--
! 111: string(5) "05:08"
! 112: float(5.133%d)
! 113: int(1218172081)
! 114:
! 115: --int 12345--
! 116: string(5) "21:45"
! 117: float(21.759%d)
! 118: int(1218145534)
! 119:
! 120: --int -12345--
! 121: string(5) "12:41"
! 122: float(12.698%d)
! 123: int(1218199315)
! 124:
! 125: --empty array--
! 126:
! 127: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 128: bool(false)
! 129:
! 130: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 131: bool(false)
! 132:
! 133: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 134: bool(false)
! 135:
! 136: --int indexed array--
! 137:
! 138: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 139: bool(false)
! 140:
! 141: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 142: bool(false)
! 143:
! 144: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 145: bool(false)
! 146:
! 147: --associative array--
! 148:
! 149: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 150: bool(false)
! 151:
! 152: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 153: bool(false)
! 154:
! 155: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 156: bool(false)
! 157:
! 158: --nested arrays--
! 159:
! 160: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 161: bool(false)
! 162:
! 163: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 164: bool(false)
! 165:
! 166: Warning: date_sunrise() expects parameter 4 to be double, array given in %s on line %d
! 167: bool(false)
! 168:
! 169: --uppercase NULL--
! 170: string(5) "05:12"
! 171: float(5.200%d)
! 172: int(1218172321)
! 173:
! 174: --lowercase null--
! 175: string(5) "05:12"
! 176: float(5.200%d)
! 177: int(1218172321)
! 178:
! 179: --lowercase true--
! 180: string(5) "05:08"
! 181: float(5.133%d)
! 182: int(1218172081)
! 183:
! 184: --lowercase false--
! 185: string(5) "05:12"
! 186: float(5.200%d)
! 187: int(1218172321)
! 188:
! 189: --uppercase TRUE--
! 190: string(5) "05:08"
! 191: float(5.133%d)
! 192: int(1218172081)
! 193:
! 194: --uppercase FALSE--
! 195: string(5) "05:12"
! 196: float(5.200%d)
! 197: int(1218172321)
! 198:
! 199: --empty string DQ--
! 200:
! 201: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 202: bool(false)
! 203:
! 204: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 205: bool(false)
! 206:
! 207: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 208: bool(false)
! 209:
! 210: --empty string SQ--
! 211:
! 212: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 213: bool(false)
! 214:
! 215: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 216: bool(false)
! 217:
! 218: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 219: bool(false)
! 220:
! 221: --string DQ--
! 222:
! 223: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 224: bool(false)
! 225:
! 226: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 227: bool(false)
! 228:
! 229: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 230: bool(false)
! 231:
! 232: --string SQ--
! 233:
! 234: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 235: bool(false)
! 236:
! 237: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 238: bool(false)
! 239:
! 240: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 241: bool(false)
! 242:
! 243: --mixed case string--
! 244:
! 245: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 246: bool(false)
! 247:
! 248: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 249: bool(false)
! 250:
! 251: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 252: bool(false)
! 253:
! 254: --heredoc--
! 255:
! 256: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 257: bool(false)
! 258:
! 259: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 260: bool(false)
! 261:
! 262: Warning: date_sunrise() expects parameter 4 to be double, string given in %s on line %d
! 263: bool(false)
! 264:
! 265: --instance of classWithToString--
! 266:
! 267: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 268: bool(false)
! 269:
! 270: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 271: bool(false)
! 272:
! 273: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 274: bool(false)
! 275:
! 276: --instance of classWithoutToString--
! 277:
! 278: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 279: bool(false)
! 280:
! 281: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 282: bool(false)
! 283:
! 284: Warning: date_sunrise() expects parameter 4 to be double, object given in %s on line %d
! 285: bool(false)
! 286:
! 287: --undefined var--
! 288: string(5) "05:12"
! 289: float(5.200%d)
! 290: int(1218172321)
! 291:
! 292: --unset var--
! 293: string(5) "05:12"
! 294: float(5.200%d)
! 295: int(1218172321)
! 296: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>