Annotation of embedaddon/php/ext/standard/tests/file/chmod_variation3.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test chmod() function : first 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 (if any)
! 23: $mode = 0777;
! 24:
! 25: //get an unset variable
! 26: $unset_var = 10;
! 27: unset ($unset_var);
! 28:
! 29: // define some classes
! 30: class classWithToString
! 31: {
! 32: public function __toString() {
! 33: return "Class A object";
! 34: }
! 35: }
! 36:
! 37: class classWithoutToString
! 38: {
! 39: }
! 40:
! 41: // heredoc string
! 42: $heredoc = <<<EOT
! 43: hello world
! 44: EOT;
! 45:
! 46: // add arrays
! 47: $index_array = array (1, 2, 3);
! 48: $assoc_array = array ('one' => 1, 'two' => 2);
! 49:
! 50: //array of values to iterate over
! 51: $inputs = array(
! 52:
! 53: // int data
! 54: 'int 0' => 0,
! 55: 'int 1' => 1,
! 56: 'int 12345' => 12345,
! 57: 'int -12345' => -2345,
! 58:
! 59: // float data
! 60: 'float 10.5' => 10.5,
! 61: 'float -10.5' => -10.5,
! 62: 'float 12.3456789000e10' => 12.3456789000e10,
! 63: 'float -12.3456789000e10' => -12.3456789000e10,
! 64: 'float .5' => .5,
! 65:
! 66: // array data
! 67: 'empty array' => array(),
! 68: 'int indexed array' => $index_array,
! 69: 'associative array' => $assoc_array,
! 70: 'nested arrays' => array('foo', $index_array, $assoc_array),
! 71:
! 72: // null data
! 73: 'uppercase NULL' => NULL,
! 74: 'lowercase null' => null,
! 75:
! 76: // boolean data
! 77: 'lowercase true' => true,
! 78: 'lowercase false' =>false,
! 79: 'uppercase TRUE' =>TRUE,
! 80: 'uppercase FALSE' =>FALSE,
! 81:
! 82: // empty data
! 83: 'empty string DQ' => "",
! 84: 'empty string SQ' => '',
! 85:
! 86: // object data
! 87: 'instance of classWithToString' => new classWithToString(),
! 88: 'instance of classWithoutToString' => new classWithoutToString(),
! 89:
! 90: // undefined data
! 91: 'undefined var' => @$undefined_var,
! 92:
! 93: // unset data
! 94: 'unset var' => @$unset_var,
! 95: );
! 96:
! 97: // loop through each element of the array for filename
! 98:
! 99: foreach($inputs as $key =>$value) {
! 100: echo "\n--$key--\n";
! 101: var_dump( chmod($value, $mode) );
! 102: };
! 103:
! 104: ?>
! 105: ===DONE===
! 106: --EXPECTF--
! 107: *** Testing chmod() : usage variation ***
! 108:
! 109: --int 0--
! 110: Error: 2 - chmod(): No such file or directory, %s(%d)
! 111: bool(false)
! 112:
! 113: --int 1--
! 114: Error: 2 - chmod(): No such file or directory, %s(%d)
! 115: bool(false)
! 116:
! 117: --int 12345--
! 118: Error: 2 - chmod(): No such file or directory, %s(%d)
! 119: bool(false)
! 120:
! 121: --int -12345--
! 122: Error: 2 - chmod(): No such file or directory, %s(%d)
! 123: bool(false)
! 124:
! 125: --float 10.5--
! 126: Error: 2 - chmod(): No such file or directory, %s(%d)
! 127: bool(false)
! 128:
! 129: --float -10.5--
! 130: Error: 2 - chmod(): No such file or directory, %s(%d)
! 131: bool(false)
! 132:
! 133: --float 12.3456789000e10--
! 134: Error: 2 - chmod(): No such file or directory, %s(%d)
! 135: bool(false)
! 136:
! 137: --float -12.3456789000e10--
! 138: Error: 2 - chmod(): No such file or directory, %s(%d)
! 139: bool(false)
! 140:
! 141: --float .5--
! 142: Error: 2 - chmod(): No such file or directory, %s(%d)
! 143: bool(false)
! 144:
! 145: --empty array--
! 146: Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
! 147: NULL
! 148:
! 149: --int indexed array--
! 150: Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
! 151: NULL
! 152:
! 153: --associative array--
! 154: Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
! 155: NULL
! 156:
! 157: --nested arrays--
! 158: Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
! 159: NULL
! 160:
! 161: --uppercase NULL--
! 162: Error: 2 - chmod(): %s, %s(%d)
! 163: bool(false)
! 164:
! 165: --lowercase null--
! 166: Error: 2 - chmod(): %s, %s(%d)
! 167: bool(false)
! 168:
! 169: --lowercase true--
! 170: Error: 2 - chmod(): No such file or directory, %s(%d)
! 171: bool(false)
! 172:
! 173: --lowercase false--
! 174: Error: 2 - chmod(): %s, %s(%d)
! 175: bool(false)
! 176:
! 177: --uppercase TRUE--
! 178: Error: 2 - chmod(): No such file or directory, %s(%d)
! 179: bool(false)
! 180:
! 181: --uppercase FALSE--
! 182: Error: 2 - chmod(): %s, %s(%d)
! 183: bool(false)
! 184:
! 185: --empty string DQ--
! 186: Error: 2 - chmod(): %s, %s(%d)
! 187: bool(false)
! 188:
! 189: --empty string SQ--
! 190: Error: 2 - chmod(): %s, %s(%d)
! 191: bool(false)
! 192:
! 193: --instance of classWithToString--
! 194: Error: 2 - chmod(): No such file or directory, %s(%d)
! 195: bool(false)
! 196:
! 197: --instance of classWithoutToString--
! 198: Error: 2 - chmod() expects parameter 1 to be string, object given, %s(%d)
! 199: NULL
! 200:
! 201: --undefined var--
! 202: Error: 2 - chmod(): %s, %s(%d)
! 203: bool(false)
! 204:
! 205: --unset var--
! 206: Error: 2 - chmod(): %s, %s(%d)
! 207: bool(false)
! 208: ===DONE===
! 209:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>