Return to fgetss_error.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test fgetss() function : error conditions 3: --FILE-- 4: <?php 5: /* 6: Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] ); 7: Description: Gets line from file pointer and strip HTML tags 8: */ 9: 10: echo "*** Testing error conditions ***\n"; 11: // zero argument 12: echo "-- Testing fgetss() with zero argument --\n"; 13: var_dump( fgetss() ); 14: 15: // more than expected no. of args 16: echo "-- Testing fgetss() with more than expected number of arguments --\n"; 17: $fp = fopen(__FILE__, "r"); 18: var_dump( fgetss($fp, 100, '<p><a>', $fp) ); 19: 20: // invalid length argument 21: echo "-- Testing fgetss() with invalid length arguments --\n"; 22: $len = 0; 23: $allowable_tags = '<p><a>'; 24: var_dump( fgetss($fp, $len, $allowable_tags) ); 25: $len = -10; 26: var_dump( fgetss($fp, $len, $allowable_tags) ); 27: $len = 1; 28: var_dump( fgetss($fp, $len, $allowable_tags) ); // return length - 1 always, expect false 29: 30: // test invalid arguments : non-resources 31: echo "-- Testing fgetss() with invalid arguments --\n"; 32: $invalid_args = array ( 33: "string", 34: 10, 35: 10.5, 36: true, 37: array(1,2,3), 38: new stdclass, 39: ); 40: /* loop to test fgetss() with different invalid type of args */ 41: for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) { 42: echo "-- Iteration $loop_counter --\n"; 43: var_dump( fgetss($invalid_args[$loop_counter - 1], 10, $allowable_tags) ); 44: } 45: // fgetss() on a file handle which is already closed 46: echo "-- Testing fgetss() with closed/unset file handle --"; 47: fclose($fp); 48: var_dump(fgetss($fp,10,$allowable_tags)); 49: 50: // fgetss() on a file handle which is unset 51: $file_handle = fopen(__FILE__, "r"); 52: unset($file_handle); //unset file handle 53: var_dump( fgetss(@$file_handle,10)); 54: 55: echo "Done\n"; 56: ?> 57: --EXPECTF-- 58: *** Testing error conditions *** 59: -- Testing fgetss() with zero argument -- 60: 61: Warning: fgetss() expects at least 1 parameter, 0 given in %s on line %d 62: bool(false) 63: -- Testing fgetss() with more than expected number of arguments -- 64: 65: Warning: fgetss() expects at most 3 parameters, 4 given in %s on line %d 66: bool(false) 67: -- Testing fgetss() with invalid length arguments -- 68: 69: Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d 70: bool(false) 71: 72: Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d 73: bool(false) 74: bool(false) 75: -- Testing fgetss() with invalid arguments -- 76: -- Iteration 1 -- 77: 78: Warning: fgetss() expects parameter 1 to be resource, string given in %s on line %d 79: bool(false) 80: -- Iteration 2 -- 81: 82: Warning: fgetss() expects parameter 1 to be resource, integer given in %s on line %d 83: bool(false) 84: -- Iteration 3 -- 85: 86: Warning: fgetss() expects parameter 1 to be resource, double given in %s on line %d 87: bool(false) 88: -- Iteration 4 -- 89: 90: Warning: fgetss() expects parameter 1 to be resource, boolean given in %s on line %d 91: bool(false) 92: -- Iteration 5 -- 93: 94: Warning: fgetss() expects parameter 1 to be resource, array given in %s on line %d 95: bool(false) 96: -- Iteration 6 -- 97: 98: Warning: fgetss() expects parameter 1 to be resource, object given in %s on line %d 99: bool(false) 100: -- Testing fgetss() with closed/unset file handle -- 101: Warning: fgetss(): 5 is not a valid stream resource in %s on line %d 102: bool(false) 103: 104: Warning: fgetss() expects parameter 1 to be resource, null given in %s on line %d 105: bool(false) 106: Done