Annotation of embedaddon/php/ext/standard/tests/filters/stream_filter_remove_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test stream_filter_remove() function : error conditions
3: --SKIPIF--
4: <?php
5: $filters = stream_get_filters();
6: if(! 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';
17: touch( $file );
18: $fp = fopen( $file, 'w+' );
19: $filter = stream_filter_append( $fp, "string.rot13", STREAM_FILTER_WRITE );
20:
21: echo "*** Testing stream_filter_remove() : error conditions ***\n";
22:
23: echo "\n-- Testing stream_filter_remove() function with Zero arguments --\n";
24: var_dump( stream_filter_remove() );
25:
26: echo "\n-- Testing stream_filter_remove() function with more than expected no. of arguments --\n";
27: $arg = 'bogus arg';
28: var_dump( stream_filter_remove( $filter, $arg ) );
29:
30: echo "\n-- Testing stream_filter_remove() function with unexisting stream filter --\n";
31: var_dump( stream_filter_remove( "fakefilter" ) );
32:
33: echo "\n-- Testing stream_filter_remove() function with bad resource --\n";
34: var_dump( stream_filter_remove( $fp ) );
35:
36: echo "\n-- Testing stream_filter_remove() function with an already removed filter --\n";
37: // Double remove it
38: var_dump( stream_filter_remove( $filter ) );
39: var_dump( stream_filter_remove( $filter ) );
40:
41: fclose( $fp );
42:
43: ?>
44: ===DONE===
45: --CLEAN--
46: <?php
47:
48: $file = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'streamfilterTest.txt';
49: unlink( $file );
50:
51: ?>
52: --EXPECTF--
53: *** Testing stream_filter_remove() : error conditions ***
54:
55: -- Testing stream_filter_remove() function with Zero arguments --
56:
57: Warning: stream_filter_remove() expects exactly 1 parameter, 0 given in %s on line %d
58: bool(false)
59:
60: -- Testing stream_filter_remove() function with more than expected no. of arguments --
61:
62: Warning: stream_filter_remove() expects exactly 1 parameter, 2 given in %s on line %d
63: bool(false)
64:
65: -- Testing stream_filter_remove() function with unexisting stream filter --
66:
67: Warning: stream_filter_remove() expects parameter 1 to be resource, string given in %s on line %d
68: bool(false)
69:
70: -- Testing stream_filter_remove() function with bad resource --
71:
72: Warning: stream_filter_remove(): Invalid resource given, not a stream filter in %s on line %d
73: bool(false)
74:
75: -- Testing stream_filter_remove() function with an already removed filter --
76: bool(true)
77:
78: Warning: stream_filter_remove(): Invalid resource given, not a stream filter in %s on line %d
79: bool(false)
80: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>