1--TEST-- 2Test stream_filter_remove() function : error conditions 3--SKIPIF-- 4<?php 5$filters = stream_get_filters(); 6if(! in_array( "string.rot13", $filters )) die( "skip rot13 filter not available." ); 7?> 8--FILE-- 9<?php 10/* Prototype : bool stream_filter_remove(resource stream_filter) 11 * Description: Flushes any data in the filter's internal buffer, removes it from the chain, and frees the resource 12 * Source code: ext/standard/streamsfuncs.c 13 * Alias to functions: 14 */ 15 16$file = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'streamfilterTest.txt'; 17touch( $file ); 18$fp = fopen( $file, 'w+' ); 19$filter = stream_filter_append( $fp, "string.rot13", STREAM_FILTER_WRITE ); 20 21echo "*** Testing stream_filter_remove() : error conditions ***\n"; 22 23echo "\n-- Testing stream_filter_remove() function with Zero arguments --\n"; 24var_dump( stream_filter_remove() ); 25 26echo "\n-- Testing stream_filter_remove() function with more than expected no. of arguments --\n"; 27$arg = 'bogus arg'; 28var_dump( stream_filter_remove( $filter, $arg ) ); 29 30echo "\n-- Testing stream_filter_remove() function with unexisting stream filter --\n"; 31var_dump( stream_filter_remove( "fakefilter" ) ); 32 33echo "\n-- Testing stream_filter_remove() function with bad resource --\n"; 34var_dump( stream_filter_remove( $fp ) ); 35 36echo "\n-- Testing stream_filter_remove() function with an already removed filter --\n"; 37// Double remove it 38var_dump( stream_filter_remove( $filter ) ); 39var_dump( stream_filter_remove( $filter ) ); 40 41fclose( $fp ); 42 43?> 44===DONE=== 45--CLEAN-- 46<?php 47 48$file = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'streamfilterTest.txt'; 49unlink( $file ); 50 51?> 52--EXPECTF-- 53*** Testing stream_filter_remove() : error conditions *** 54 55-- Testing stream_filter_remove() function with Zero arguments -- 56 57Warning: stream_filter_remove() expects exactly 1 parameter, 0 given in %s on line %d 58bool(false) 59 60-- Testing stream_filter_remove() function with more than expected no. of arguments -- 61 62Warning: stream_filter_remove() expects exactly 1 parameter, 2 given in %s on line %d 63bool(false) 64 65-- Testing stream_filter_remove() function with unexisting stream filter -- 66 67Warning: stream_filter_remove() expects parameter 1 to be resource, string given in %s on line %d 68bool(false) 69 70-- Testing stream_filter_remove() function with bad resource -- 71 72Warning: stream_filter_remove(): Invalid resource given, not a stream filter in %s on line %d 73bool(false) 74 75-- Testing stream_filter_remove() function with an already removed filter -- 76bool(true) 77 78Warning: stream_filter_remove(): Invalid resource given, not a stream filter in %s on line %d 79bool(false) 80===DONE=== 81