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, integer given, %s(%d) 127bool(false) 128 129--int 1-- 130Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d) 131bool(false) 132 133--int 12345-- 134Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d) 135bool(false) 136 137--int -12345-- 138Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d) 139bool(false) 140 141--float 10.5-- 142Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d) 143bool(false) 144 145--float -10.5-- 146Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d) 147bool(false) 148 149--float 12.3456789000e10-- 150Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d) 151bool(false) 152 153--float -12.3456789000e10-- 154Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d) 155bool(false) 156 157--float .5-- 158Error: 2 - rmdir() expects parameter 2 to be resource, double 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-- 178Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) 179bool(false) 180 181--lowercase null-- 182Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) 183bool(false) 184 185--lowercase true-- 186Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d) 187bool(false) 188 189--lowercase false-- 190Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d) 191bool(false) 192 193--uppercase TRUE-- 194Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d) 195bool(false) 196 197--uppercase FALSE-- 198Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d) 199bool(false) 200 201--empty string DQ-- 202Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 203bool(false) 204 205--empty string SQ-- 206Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 207bool(false) 208 209--string DQ-- 210Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 211bool(false) 212 213--string SQ-- 214Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 215bool(false) 216 217--mixed case string-- 218Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 219bool(false) 220 221--heredoc-- 222Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d) 223bool(false) 224 225--instance of classWithToString-- 226Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d) 227bool(false) 228 229--instance of classWithoutToString-- 230Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d) 231bool(false) 232 233--undefined var-- 234Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) 235bool(false) 236 237--unset var-- 238Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) 239bool(false) 240 241--0-- 242Error: 2 - rmdir(): supplied resource is not a valid Stream-Context resource, %s(%d) 243bool(true) 244===DONE=== 245