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
13$context = stream_context_create();
14
15$file_path = __DIR__;
16
17echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
18var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true, $context) );
19var_dump( rmdir("$file_path/mkdir_variation2/test/", $context) );
20
21echo "\n*** Testing rmdir() on a non-empty directory ***\n";
22var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true) );
23var_dump( rmdir("$file_path/mkdir_variation2/") );
24
25echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
26try {
27    var_dump( mkdir("$file_path/temp".chr(0)."/") );
28} catch (ValueError $e) {
29    echo $e->getMessage(), "\n";
30}
31try {
32    var_dump( rmdir("$file_path/temp".chr(0)."/") );
33} catch (ValueError $e) {
34    echo $e->getMessage(), "\n";
35}
36
37echo "\n*** Testing mkdir() with miscellaneous input ***\n";
38/* changing mode of mkdir to prevent creating sub-directory under it */
39var_dump( chmod("$file_path/mkdir_variation2/", 0000) );
40/* creating sub-directory test1 under mkdir, expected: false */
41var_dump( mkdir("$file_path/mkdir_variation2/test1", 0777, true) );
42var_dump( chmod("$file_path/mkdir_variation2/", 0777) );  // chmod to enable removing test1 directory
43
44echo "Done\n";
45?>
46--CLEAN--
47<?php
48rmdir(__DIR__."/mkdir_variation2/test/");
49rmdir(__DIR__."/mkdir_variation2/");
50?>
51--EXPECTF--
52*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
53bool(true)
54bool(true)
55
56*** Testing rmdir() on a non-empty directory ***
57bool(true)
58
59Warning: rmdir(%s/mkdir_variation2/): %s on line %d
60bool(false)
61
62*** Testing mkdir() and rmdir() for binary safe functionality ***
63mkdir(): Argument #1 ($directory) must not contain any null bytes
64rmdir(): Argument #1 ($directory) must not contain any null bytes
65
66*** Testing mkdir() with miscellaneous input ***
67bool(true)
68
69Warning: mkdir(): Permission denied in %s on line %d
70bool(false)
71bool(true)
72Done
73