diff options
Diffstat (limited to 'ext/standard/tests/file/touch_variation5.phpt')
-rw-r--r-- | ext/standard/tests/file/touch_variation5.phpt | 112 |
1 files changed, 52 insertions, 60 deletions
diff --git a/ext/standard/tests/file/touch_variation5.phpt b/ext/standard/tests/file/touch_variation5.phpt index 7eb4aaa7e0..a4a9cf6928 100644 --- a/ext/standard/tests/file/touch_variation5.phpt +++ b/ext/standard/tests/file/touch_variation5.phpt @@ -10,19 +10,13 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { ?> --FILE-- <?php -/* Prototype : bool touch(string filename [, int time [, int atime]]) - * Description: Set modification time of file - * Source code: ext/standard/filestat.c - * Alias to functions: - */ - $workDir = "touchVar5.tmp"; $subDirOrFile = "aSubDirOrFile"; mkdir($workDir); $cwd = getcwd(); $paths = array( - // relative + // relative $workDir.'/'.$subDirOrFile, './'.$workDir.'/'.$subDirOrFile, $workDir.'/../'.$workDir.'/'.$subDirOrFile, @@ -66,66 +60,66 @@ rmdir($workDir); function test_nonexisting($paths) { - foreach($paths as $path) { - echo "--- testing $path ---\n"; - - if (is_dir($path) || is_file($path)) { - echo "FAILED: $path - exists\n"; - } - else { - $res = touch($path); - if ($res === true) { - // something was created - if (file_exists($path)) { - // something found - if (is_dir($path)) { - echo "FAILED: $path - unexpected directory\n"; - } - else { - echo "PASSED: $path - created\n"; - unlink($path); - } - } - else { - // nothing found - echo "FAILED: $path - touch returned true, nothing there\n"; - } - } - else { - // nothing created - if (file_exists($path)) { - //something found - echo "FAILED: $path - touch returned false, something there\n"; - if (is_dir($path)) { - rmdir($path); - } - else { - unlink($path); - } - } - } - } - } + foreach($paths as $path) { + echo "--- testing $path ---\n"; + + if (is_dir($path) || is_file($path)) { + echo "FAILED: $path - exists\n"; + } + else { + $res = touch($path); + if ($res === true) { + // something was created + if (file_exists($path)) { + // something found + if (is_dir($path)) { + echo "FAILED: $path - unexpected directory\n"; + } + else { + echo "PASSED: $path - created\n"; + unlink($path); + } + } + else { + // nothing found + echo "FAILED: $path - touch returned true, nothing there\n"; + } + } + else { + // nothing created + if (file_exists($path)) { + //something found + echo "FAILED: $path - touch returned false, something there\n"; + if (is_dir($path)) { + rmdir($path); + } + else { + unlink($path); + } + } + } + } + } } function test_existing($paths, $are_dirs) { - foreach($paths as $path) { - if ($are_dirs) { - $res = @mkdir($path); - if ($res == true) { + foreach($paths as $path) { + if ($are_dirs) { + $res = @mkdir($path); + if ($res == true) { test_path($path); rmdir($path); } - } - else { - $h = @fopen($path,"w"); - if ($h !== false) { - fclose($h); + } + else { + $h = @fopen($path,"w"); + if ($h !== false) { + fclose($h); test_path($path); unlink($path); } - } - } + } + } } @@ -150,7 +144,6 @@ function get_atime($path) { ?> -===DONE=== --EXPECTF-- *** Testing touch() : variation *** @@ -226,4 +219,3 @@ PASSED: /%s/touchVar5.tmp/aSubDirOrFile/ - touched PASSED: touchVar5.tmp//aSubDirOrFile - touched --- testing /%s//touchVar5.tmp//aSubDirOrFile --- PASSED: /%s//touchVar5.tmp//aSubDirOrFile - touched -===DONE=== |