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