chmod_variation3.phpt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. echo "*** Testing chmod() : usage variation ***\n";
  11. // Define error handler
  12. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  13. if (error_reporting() != 0) {
  14. // report non-silenced errors
  15. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  16. }
  17. }
  18. set_error_handler('test_error_handler');
  19. // Initialise function arguments not being substituted (if any)
  20. $mode = 0777;
  21. //get an unset variable
  22. $unset_var = 10;
  23. unset ($unset_var);
  24. // define some classes
  25. class classWithToString
  26. {
  27. public function __toString() {
  28. return "Class A object";
  29. }
  30. }
  31. class classWithoutToString
  32. {
  33. }
  34. // heredoc string
  35. $heredoc = <<<EOT
  36. hello world
  37. EOT;
  38. // add arrays
  39. $index_array = array (1, 2, 3);
  40. $assoc_array = array ('one' => 1, 'two' => 2);
  41. //array of values to iterate over
  42. $inputs = array(
  43. // int data
  44. 'int 0' => 0,
  45. 'int 1' => 1,
  46. 'int 12345' => 12345,
  47. 'int -12345' => -2345,
  48. // float data
  49. 'float 10.5' => 10.5,
  50. 'float -10.5' => -10.5,
  51. 'float 12.3456789000e10' => 12.3456789000e10,
  52. 'float -12.3456789000e10' => -12.3456789000e10,
  53. 'float .5' => .5,
  54. // array data
  55. 'empty array' => array(),
  56. 'int indexed array' => $index_array,
  57. 'associative array' => $assoc_array,
  58. 'nested arrays' => array('foo', $index_array, $assoc_array),
  59. // null data
  60. 'uppercase NULL' => NULL,
  61. 'lowercase null' => null,
  62. // boolean data
  63. 'lowercase true' => true,
  64. 'lowercase false' =>false,
  65. 'uppercase TRUE' =>TRUE,
  66. 'uppercase FALSE' =>FALSE,
  67. // empty data
  68. 'empty string DQ' => "",
  69. 'empty string SQ' => '',
  70. // object data
  71. 'instance of classWithToString' => new classWithToString(),
  72. 'instance of classWithoutToString' => new classWithoutToString(),
  73. // undefined data
  74. 'undefined var' => @$undefined_var,
  75. // unset data
  76. 'unset var' => @$unset_var,
  77. );
  78. // loop through each element of the array for filename
  79. foreach($inputs as $key =>$value) {
  80. echo "\n--$key--\n";
  81. var_dump( chmod($value, $mode) );
  82. };
  83. ?>
  84. ===DONE===
  85. --EXPECTF--
  86. *** Testing chmod() : usage variation ***
  87. --int 0--
  88. Error: 2 - chmod(): No such file or directory, %s(%d)
  89. bool(false)
  90. --int 1--
  91. Error: 2 - chmod(): No such file or directory, %s(%d)
  92. bool(false)
  93. --int 12345--
  94. Error: 2 - chmod(): No such file or directory, %s(%d)
  95. bool(false)
  96. --int -12345--
  97. Error: 2 - chmod(): No such file or directory, %s(%d)
  98. bool(false)
  99. --float 10.5--
  100. Error: 2 - chmod(): No such file or directory, %s(%d)
  101. bool(false)
  102. --float -10.5--
  103. Error: 2 - chmod(): No such file or directory, %s(%d)
  104. bool(false)
  105. --float 12.3456789000e10--
  106. Error: 2 - chmod(): No such file or directory, %s(%d)
  107. bool(false)
  108. --float -12.3456789000e10--
  109. Error: 2 - chmod(): No such file or directory, %s(%d)
  110. bool(false)
  111. --float .5--
  112. Error: 2 - chmod(): No such file or directory, %s(%d)
  113. bool(false)
  114. --empty array--
  115. Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
  116. NULL
  117. --int indexed array--
  118. Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
  119. NULL
  120. --associative array--
  121. Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
  122. NULL
  123. --nested arrays--
  124. Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
  125. NULL
  126. --uppercase NULL--
  127. Error: 2 - chmod(): %s, %s(%d)
  128. bool(false)
  129. --lowercase null--
  130. Error: 2 - chmod(): %s, %s(%d)
  131. bool(false)
  132. --lowercase true--
  133. Error: 2 - chmod(): No such file or directory, %s(%d)
  134. bool(false)
  135. --lowercase false--
  136. Error: 2 - chmod(): %s, %s(%d)
  137. bool(false)
  138. --uppercase TRUE--
  139. Error: 2 - chmod(): No such file or directory, %s(%d)
  140. bool(false)
  141. --uppercase FALSE--
  142. Error: 2 - chmod(): %s, %s(%d)
  143. bool(false)
  144. --empty string DQ--
  145. Error: 2 - chmod(): %s, %s(%d)
  146. bool(false)
  147. --empty string SQ--
  148. Error: 2 - chmod(): %s, %s(%d)
  149. bool(false)
  150. --instance of classWithToString--
  151. Error: 2 - chmod(): No such file or directory, %s(%d)
  152. bool(false)
  153. --instance of classWithoutToString--
  154. Error: 2 - chmod() expects parameter 1 to be a valid path, object given, %s(%d)
  155. NULL
  156. --undefined var--
  157. Error: 2 - chmod(): %s, %s(%d)
  158. bool(false)
  159. --unset var--
  160. Error: 2 - chmod(): %s, %s(%d)
  161. bool(false)
  162. ===DONE===