Annotation of embedaddon/php/ext/standard/tests/file/fflush_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test fflush() function: error conditions
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: Prototype: bool fflush ( resource $handle );
! 7: Description: Flushes the output to a file
! 8: */
! 9:
! 10: echo "*** Testing error conditions ***\n";
! 11: $file_path = dirname(__FILE__);
! 12:
! 13: // zero argument
! 14: echo "-- Testing fflush(): with zero argument --\n";
! 15: var_dump( fflush() );
! 16:
! 17: // more than expected no. of args
! 18: echo "-- Testing fflush(): with more than expected number of arguments --\n";
! 19:
! 20: $filename = "$file_path/fflush_error.tmp";
! 21: $file_handle = fopen($filename, "w");
! 22: if($file_handle == false)
! 23: exit("Error:failed to open file $filename");
! 24:
! 25: var_dump( fflush($file_handle, $file_handle) );
! 26: fclose($file_handle);
! 27:
! 28: // test invalid arguments : non-resources
! 29: echo "-- Testing fflush(): with invalid arguments --\n";
! 30: $invalid_args = array (
! 31: "string",
! 32: 10,
! 33: 10.5,
! 34: true,
! 35: array(1,2,3),
! 36: new stdclass
! 37: );
! 38:
! 39: /* loop to test fflush() with different invalid type of args */
! 40: for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
! 41: echo "-- Iteration $loop_counter --\n";
! 42: var_dump( fflush($invalid_args[$loop_counter - 1]) );
! 43: }
! 44: echo "\n*** Done ***";
! 45: ?>
! 46:
! 47: --CLEAN--
! 48: <?php
! 49: $file_path = dirname(__FILE__);
! 50: unlink("$file_path/fflush_error.tmp");
! 51: ?>
! 52:
! 53: --EXPECTF--
! 54: *** Testing error conditions ***
! 55: -- Testing fflush(): with zero argument --
! 56:
! 57: Warning: fflush() expects exactly 1 parameter, 0 given in %s on line %d
! 58: bool(false)
! 59: -- Testing fflush(): with more than expected number of arguments --
! 60:
! 61: Warning: fflush() expects exactly 1 parameter, 2 given in %s on line %d
! 62: bool(false)
! 63: -- Testing fflush(): with invalid arguments --
! 64: -- Iteration 1 --
! 65:
! 66: Warning: fflush() expects parameter 1 to be resource, string given in %s on line %d
! 67: bool(false)
! 68: -- Iteration 2 --
! 69:
! 70: Warning: fflush() expects parameter 1 to be resource, integer given in %s on line %d
! 71: bool(false)
! 72: -- Iteration 3 --
! 73:
! 74: Warning: fflush() expects parameter 1 to be resource, double given in %s on line %d
! 75: bool(false)
! 76: -- Iteration 4 --
! 77:
! 78: Warning: fflush() expects parameter 1 to be resource, boolean given in %s on line %d
! 79: bool(false)
! 80: -- Iteration 5 --
! 81:
! 82: Warning: fflush() expects parameter 1 to be resource, array given in %s on line %d
! 83: bool(false)
! 84: -- Iteration 6 --
! 85:
! 86: Warning: fflush() expects parameter 1 to be resource, object given in %s on line %d
! 87: bool(false)
! 88:
! 89: *** Done ***
! 90:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>