1--TEST--
2Test mkdir() and rmdir() functions: usage variations - misc.
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. only on LINUX');
7}
8require __DIR__ . '/../skipif_root.inc';
9?>
10--FILE--
11<?php
12/*  Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
13    Description: Makes directory
14*/
15
16$context = stream_context_create();
17
18$file_path = __DIR__;
19
20echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
21var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true, $context) );
22var_dump( rmdir("$file_path/mkdir_variation2/test/", $context) );
23
24echo "\n*** Testing rmdir() on a non-empty directory ***\n";
25var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true) );
26var_dump( rmdir("$file_path/mkdir_variation2/") );
27
28echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
29var_dump( mkdir("$file_path/temp".chr(0)."/") );
30var_dump( rmdir("$file_path/temp".chr(0)."/") );
31
32echo "\n*** Testing mkdir() with miscelleneous input ***\n";
33/* changing mode of mkdir to prevent creating sub-directory under it */
34var_dump( chmod("$file_path/mkdir_variation2/", 0000) );
35/* creating sub-directory test1 under mkdir, expected: false */
36var_dump( mkdir("$file_path/mkdir_variation2/test1", 0777, true) );
37var_dump( chmod("$file_path/mkdir_variation2/", 0777) );  // chmod to enable removing test1 directory
38
39echo "Done\n";
40?>
41--CLEAN--
42<?php
43rmdir(__DIR__."/mkdir_variation2/test/");
44rmdir(__DIR__."/mkdir_variation2/");
45?>
46--EXPECTF--
47*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
48bool(true)
49bool(true)
50
51*** Testing rmdir() on a non-empty directory ***
52bool(true)
53
54Warning: rmdir(%s/mkdir_variation2/): %s on line %d
55bool(false)
56
57*** Testing mkdir() and rmdir() for binary safe functionality ***
58
59Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
60bool(false)
61
62Warning: rmdir() expects parameter 1 to be a valid path, string given in %s on line %d
63bool(false)
64
65*** Testing mkdir() with miscelleneous input ***
66bool(true)
67
68Warning: mkdir(): Permission denied in %s on line %d
69bool(false)
70bool(true)
71Done
72