touch_variation4-win32.phpt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. --TEST--
  2. Test touch() function : usage variation - different types for atime
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --SKIPIF--
  6. <?php
  7. if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
  8. if (substr(PHP_OS, 0, 3) != 'WIN') {
  9. die('skip.. only for Windows');
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. /* Prototype : bool touch(string filename [, int time [, int atime]])
  15. * Description: Set modification time of file
  16. * Source code: ext/standard/filestat.c
  17. * Alias to functions:
  18. */
  19. echo "*** Testing touch() : usage variation ***\n";
  20. // Define error handler
  21. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  22. if (error_reporting() != 0) {
  23. // report non-silenced errors
  24. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  25. }
  26. }
  27. set_error_handler('test_error_handler');
  28. // Initialise function arguments not being substituted (if any)
  29. $filename = 'touchVar3.tmp';
  30. $time = 10;
  31. //get an unset variable
  32. $unset_var = 10;
  33. unset ($unset_var);
  34. // define some classes
  35. class classWithToString
  36. {
  37. public function __toString() {
  38. return "Class A object";
  39. }
  40. }
  41. class classWithoutToString
  42. {
  43. }
  44. // heredoc string
  45. $heredoc = <<<EOT
  46. hello world
  47. EOT;
  48. // add arrays
  49. $index_array = array (1, 2, 3);
  50. $assoc_array = array ('one' => 1, 'two' => 2);
  51. //array of values to iterate over
  52. $inputs = array(
  53. // float data
  54. 'float 10.5' => 10.5,
  55. 'float 12.3456789000e10' => 12.3456789000e10,
  56. 'float .5' => .5,
  57. // array data
  58. 'empty array' => array(),
  59. 'int indexed array' => $index_array,
  60. 'associative array' => $assoc_array,
  61. 'nested arrays' => array('foo', $index_array, $assoc_array),
  62. // null data
  63. 'uppercase NULL' => NULL,
  64. 'lowercase null' => null,
  65. // boolean data
  66. 'lowercase true' => true,
  67. 'lowercase false' =>false,
  68. 'uppercase TRUE' =>TRUE,
  69. 'uppercase FALSE' =>FALSE,
  70. // empty data
  71. 'empty string DQ' => "",
  72. 'empty string SQ' => '',
  73. // string data
  74. 'string DQ' => "string",
  75. 'string SQ' => 'string',
  76. 'mixed case string' => "sTrInG",
  77. 'heredoc' => $heredoc,
  78. // object data
  79. 'instance of classWithToString' => new classWithToString(),
  80. 'instance of classWithoutToString' => new classWithoutToString(),
  81. // undefined data
  82. 'undefined var' => @$undefined_var,
  83. // unset data
  84. 'unset var' => @$unset_var,
  85. );
  86. // loop through each element of the array for atime
  87. foreach($inputs as $key =>$value) {
  88. echo "\n--$key--\n";
  89. var_dump( touch($filename, $time, $value) );
  90. };
  91. unlink($filename);
  92. ?>
  93. ===DONE===
  94. --EXPECTF--
  95. *** Testing touch() : usage variation ***
  96. --float 10.5--
  97. bool(true)
  98. --float 12.3456789000e10--
  99. bool(true)
  100. --float .5--
  101. bool(true)
  102. --empty array--
  103. Error: 2 - touch() expects parameter 3 to be int, array given, %s(%d)
  104. NULL
  105. --int indexed array--
  106. Error: 2 - touch() expects parameter 3 to be int, array given, %s(%d)
  107. NULL
  108. --associative array--
  109. Error: 2 - touch() expects parameter 3 to be int, array given, %s(%d)
  110. NULL
  111. --nested arrays--
  112. Error: 2 - touch() expects parameter 3 to be int, array given, %s(%d)
  113. NULL
  114. --uppercase NULL--
  115. bool(true)
  116. --lowercase null--
  117. bool(true)
  118. --lowercase true--
  119. bool(true)
  120. --lowercase false--
  121. bool(true)
  122. --uppercase TRUE--
  123. bool(true)
  124. --uppercase FALSE--
  125. bool(true)
  126. --empty string DQ--
  127. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  128. NULL
  129. --empty string SQ--
  130. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  131. NULL
  132. --string DQ--
  133. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  134. NULL
  135. --string SQ--
  136. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  137. NULL
  138. --mixed case string--
  139. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  140. NULL
  141. --heredoc--
  142. Error: 2 - touch() expects parameter 3 to be int, string given, %s(%d)
  143. NULL
  144. --instance of classWithToString--
  145. Error: 2 - touch() expects parameter 3 to be int, object given, %s(%d)
  146. NULL
  147. --instance of classWithoutToString--
  148. Error: 2 - touch() expects parameter 3 to be int, object given, %s(%d)
  149. NULL
  150. --undefined var--
  151. bool(true)
  152. --unset var--
  153. bool(true)
  154. ===DONE===