1--TEST-- 2Test rmdir() function : usage variation - different types for context 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--FILE-- 6<?php 7/* Prototype : bool rmdir(string dirname[, resource context]) 8 * Description: Remove a directory 9 * Source code: ext/standard/file.c 10 * Alias to functions: 11 */ 12 13echo "*** Testing rmdir() : usage variation ***\n"; 14 15// Define error handler 16function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { 17 if (error_reporting() != 0) { 18 // report non-silenced errors 19 echo "Error: $err_no - $err_msg, $filename($linenum)\n"; 20 } 21} 22set_error_handler('test_error_handler'); 23 24// Initialise function arguments not being substituted (if any) 25$dirname = 'rmdirVar2.tmp'; 26 27//get an unset variable 28$unset_var = 10; 29unset ($unset_var); 30 31// define some classes 32class classWithToString 33{ 34 public function __toString() { 35 return "Class A object"; 36 } 37} 38 39class classWithoutToString 40{ 41} 42 43// heredoc string 44$heredoc = <<<EOT 45hello world 46EOT; 47 48// add arrays 49$index_array = array (1, 2, 3); 50$assoc_array = array ('one' => 1, 'two' => 2); 51 52$fileres = fopen(__FILE__, 'r'); 53 54//array of values to iterate over 55$inputs = array( 56 57 // int data 58 'int 0' => 0, 59 'int 1' => 1, 60 'int 12345' => 12345, 61 'int -12345' => -2345, 62 63 // float data 64 'float 10.5' => 10.5, 65 'float -10.5' => -10.5, 66 'float 12.3456789000e10' => 12.3456789000e10, 67 'float -12.3456789000e10' => -12.3456789000e10, 68 'float .5' => .5, 69 70 // array data 71 'empty array' => array(), 72 'int indexed array' => $index_array, 73 'associative array' => $assoc_array, 74 'nested arrays' => array('foo', $index_array, $assoc_array), 75 76 // null data 77 'uppercase NULL' => NULL, 78 'lowercase null' => null, 79 80 // boolean data 81 'lowercase true' => true, 82 'lowercase false' =>false, 83 'uppercase TRUE' =>TRUE, 84 'uppercase FALSE' =>FALSE, 85 86 // empty data 87 'empty string DQ' => "", 88 'empty string SQ' => '', 89 90 // string data 91 'string DQ' => "string", 92 'string SQ' => 'string', 93 'mixed case string' => "sTrInG", 94 'heredoc' => $heredoc, 95 96 // object data 97 'instance of classWithToString' => new classWithToString(), 98 'instance of classWithoutToString' => new classWithoutToString(), 99 100 // undefined data 101 'undefined var' => @$undefined_var, 102 103 // unset data 104 'unset var' => @$unset_var, 105 106 // non stream context resource 107 $fileres, 108); 109 110// loop through each element of the array for context 111 112foreach($inputs as $key =>$value) { 113 echo "\n--$key--\n"; 114 @mkdir($dirname); 115 var_dump( rmdir($dirname, $value) ); 116}; 117 118@rmdir($dirname); 119fclose($fileres); 120?> 121===DONE=== 122--EXPECTF-- 123*** Testing rmdir() : usage variation *** 124 125--int 0-- 126Error: 2 - rmdir() expects parameter 2 to be resource, int given, %s(%d) 127bool(false) 128 129--int 1-- 130Error: 2 - rmdir() expects parameter 2 to be resource, int given, %s(%d) 131bool(false) 132 133--int 12345-- 134Error: 2 - rmdir() expects parameter 2 to be resource, int given, %s(%d) 135bool(false) 136 137--int -12345-- 138Error: 2 - rmdir() expects parameter 2 to be resource, int given, %s(%d) 139bool(false) 140 141--float 10.5-- 142Error: 2 - rmdir() expects parameter 2 to be resource, float given, %s(%d) 143bool(false) 144 145--float -10.5-- 146Error: 2 - rmdir() expects parameter 2 to be resource, float given, %s(%d) 147bool(false) 148 149--float 12.3456789000e10-- 150Error: 2 - rmdir() expects parameter 2 to be resource, float given, %s(%d) 151bool(false) 152 153--float -12.3456789000e10-- 154Error: 2 - rmdir() expects parameter 2 to be resource, float given, %s(%d) 155bool(false) 156 157--float .5-- 158Error: 2 - rmdir() expects parameter 2 to be resource, float given, %s(%d) 159bool(false) 160 161--empty array-- 162Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d) 163bool(false) 164 165--int indexed array-- 166Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d) 167bool(false) 168 169--associative array-- 170Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d) 171bool(false) 172 173--nested arrays-- 174Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d) 175bool(false) 176 177--uppercase NULL-- 178bool(true) 179 180--lowercase null-- 181bool(true) 182 183--lowercase true-- 184Error: 2 - rmdir() expects parameter 2 to be resource, bool given, %s(%d) 185bool(false) 186 187--lowercase false-- 188Error: 2 - rmdir() expects parameter 2 to be resource, bool given, %s(%d) 189bool(false) 190 191--uppercase TRUE-- 192Error: 2 - rmdir() expects parameter 2 to be resource, bool given, %s(%d) 193bool(false) 194 195--uppercase FALSE-- 196Error: 2 - rmdir() expects parameter 2 to be resource, bool given, %s(%d) 197bool(false) 198 199--empty string DQ-- 200Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 201bool(false) 202 203--empty string SQ-- 204Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 205bool(false) 206 207--string DQ-- 208Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 209bool(false) 210 211--string SQ-- 212Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 213bool(false) 214 215--mixed case string-- 216Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 217bool(false) 218 219--heredoc-- 220Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 221bool(false) 222 223--instance of classWithToString-- 224Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d) 225bool(false) 226 227--instance of classWithoutToString-- 228Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d) 229bool(false) 230 231--undefined var-- 232bool(true) 233 234--unset var-- 235bool(true) 236 237--0-- 238Error: 2 - rmdir(): supplied resource is not a valid Stream-Context resource, %s(%d) 239bool(true) 240===DONE=== 241