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