Return to chmod_variation4.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test chmod() function : second parameter variation 3: --FILE-- 4: <?php 5: /* Prototype : bool chmod(string filename, int mode) 6: * Description: Change file mode 7: * Source code: ext/standard/filestat.c 8: * Alias to functions: 9: */ 10: 11: echo "*** Testing chmod() : usage variation ***\n"; 12: 13: // Define error handler 14: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { 15: if (error_reporting() != 0) { 16: // report non-silenced errors 17: echo "Error: $err_no - $err_msg, $filename($linenum)\n"; 18: } 19: } 20: set_error_handler('test_error_handler'); 21: 22: // Initialise function arguments not being substituted 23: $filename = __FILE__ . ".tmp"; 24: $fd = fopen($filename, "w+"); 25: fclose($fd); 26: 27: //get an unset variable 28: $unset_var = 10; 29: unset ($unset_var); 30: 31: // define some classes 32: class classWithToString 33: { 34: public function __toString() { 35: return "Class A object"; 36: } 37: } 38: 39: class classWithoutToString 40: { 41: } 42: 43: // heredoc string 44: $heredoc = <<<EOT 45: hello world 46: EOT; 47: 48: // add arrays 49: $index_array = array (1, 2, 3); 50: $assoc_array = array ('one' => 1, 'two' => 2); 51: 52: //array of values to iterate over 53: $inputs = array( 54: 55: // float data 56: 'float 10.5' => 10.5, 57: 'float -10.5' => -10.5, 58: 'float 12.3456789000e10' => 12.3456789000e10, 59: 'float -12.3456789000e10' => -12.3456789000e10, 60: 'float .5' => .5, 61: 62: // array data 63: 'empty array' => array(), 64: 'int indexed array' => $index_array, 65: 'associative array' => $assoc_array, 66: 'nested arrays' => array('foo', $index_array, $assoc_array), 67: 68: // null data 69: 'uppercase NULL' => NULL, 70: 'lowercase null' => null, 71: 72: // boolean data 73: 'lowercase true' => true, 74: 'lowercase false' =>false, 75: 'uppercase TRUE' =>TRUE, 76: 'uppercase FALSE' =>FALSE, 77: 78: // empty data 79: 'empty string DQ' => "", 80: 'empty string SQ' => '', 81: 82: // string data 83: 'string DQ' => "string", 84: 'string SQ' => 'string', 85: 'mixed case string' => "sTrInG", 86: 'heredoc' => $heredoc, 87: 88: // object data 89: 'instance of classWithToString' => new classWithToString(), 90: 'instance of classWithoutToString' => new classWithoutToString(), 91: 92: // undefined data 93: 'undefined var' => @$undefined_var, 94: 95: // unset data 96: 'unset var' => @$unset_var, 97: ); 98: 99: // loop through each element of the array for mode 100: 101: foreach($inputs as $key =>$value) { 102: echo "\n--$key--\n"; 103: var_dump( chmod($filename, $value) ); 104: }; 105: 106: chmod($filename, 0777); 107: unlink($filename); 108: 109: ?> 110: ===DONE=== 111: --EXPECTF-- 112: *** Testing chmod() : usage variation *** 113: 114: --float 10.5-- 115: bool(true) 116: 117: --float -10.5-- 118: bool(true) 119: 120: --float 12.3456789000e10-- 121: bool(true) 122: 123: --float -12.3456789000e10-- 124: bool(true) 125: 126: --float .5-- 127: bool(true) 128: 129: --empty array-- 130: Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d) 131: NULL 132: 133: --int indexed array-- 134: Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d) 135: NULL 136: 137: --associative array-- 138: Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d) 139: NULL 140: 141: --nested arrays-- 142: Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d) 143: NULL 144: 145: --uppercase NULL-- 146: bool(true) 147: 148: --lowercase null-- 149: bool(true) 150: 151: --lowercase true-- 152: bool(true) 153: 154: --lowercase false-- 155: bool(true) 156: 157: --uppercase TRUE-- 158: bool(true) 159: 160: --uppercase FALSE-- 161: bool(true) 162: 163: --empty string DQ-- 164: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 165: NULL 166: 167: --empty string SQ-- 168: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 169: NULL 170: 171: --string DQ-- 172: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 173: NULL 174: 175: --string SQ-- 176: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 177: NULL 178: 179: --mixed case string-- 180: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 181: NULL 182: 183: --heredoc-- 184: Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d) 185: NULL 186: 187: --instance of classWithToString-- 188: Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d) 189: NULL 190: 191: --instance of classWithoutToString-- 192: Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d) 193: NULL 194: 195: --undefined var-- 196: bool(true) 197: 198: --unset var-- 199: bool(true) 200: ===DONE=== 201: