1--TEST--
2Test rmdir() function : variation: various valid and invalid paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--FILE--
6<?php
7/* Prototype  : bool rmdir(string dirname[, resource context])
8 * Description: Remove a directory
9 * Source code: ext/standard/file.c
10 * Alias to functions:
11 */
12
13echo "*** Testing rmdir() : variation ***\n";
14
15$workDir = "rmdirVar3.tmp";
16$subDir = "aSubDir";
17mkdir($workDir);
18$cwd = getcwd();
19
20$dirs = array(
21             // relative
22             $workDir.'/'.$subDir,
23             './'.$workDir.'/'.$subDir,
24             $workDir.'/../'.$workDir.'/'.$subDir,
25
26             // relative bad path
27             $workDir.'/../BADDIR/'.$subDir,
28             'BADDIR/'.$subDir,
29
30             //absolute
31             $cwd.'/'.$workDir.'/'.$subDir,
32             $cwd.'/./'.$workDir.'/'.$subDir,
33             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDir,
34
35             //absolute bad path
36             $cwd.'/BADDIR/'.$subDir,
37
38             //trailing separators
39             $workDir.'/'.$subDir.'/',
40             $cwd.'/'.$workDir.'/'.$subDir.'/',
41
42             // multiple separators
43             $workDir.'//'.$subDir,
44             $cwd.'//'.$workDir.'//'.$subDir,
45
46             );
47
48
49foreach($dirs as $dir) {
50   mkdir($workDir.'/'.$subDir);
51   echo "-- removing $dir --\n";
52   $res = rmdir($dir);
53   if ($res === true) {
54      echo "Directory removed\n";
55   }
56   else {
57      rmdir($workDir.'/'.$subDir);
58   }
59}
60
61rmdir($workDir);
62
63?>
64===DONE===
65--EXPECTF--
66*** Testing rmdir() : variation ***
67-- removing rmdirVar3.tmp/aSubDir --
68Directory removed
69-- removing ./rmdirVar3.tmp/aSubDir --
70Directory removed
71-- removing rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
72Directory removed
73-- removing rmdirVar3.tmp/../BADDIR/aSubDir --
74
75Warning: rmdir(rmdirVar3.tmp/../BADDIR/aSubDir): No such file or directory in %s on line %d
76-- removing BADDIR/aSubDir --
77
78Warning: rmdir(BADDIR/aSubDir): No such file or directory in %s on line %d
79-- removing %s/rmdirVar3.tmp/aSubDir --
80Directory removed
81-- removing %s/./rmdirVar3.tmp/aSubDir --
82Directory removed
83-- removing %s/rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
84Directory removed
85-- removing %s/BADDIR/aSubDir --
86
87Warning: rmdir(%s/BADDIR/aSubDir): No such file or directory in %s on line %d
88-- removing rmdirVar3.tmp/aSubDir/ --
89Directory removed
90-- removing %s/rmdirVar3.tmp/aSubDir/ --
91Directory removed
92-- removing rmdirVar3.tmp//aSubDir --
93Directory removed
94-- removing %s//rmdirVar3.tmp//aSubDir --
95Directory removed
96===DONE===