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}
8// Skip if being run by root (files are always readable, writeable and executable)
9$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
10$fp = fopen($filename, 'w');
11fclose($fp);
12if(fileowner($filename) == 0) {
13	unlink ($filename);
14	die('skip cannot be run as root');
15}
16
17unlink($filename);
18?>
19--FILE--
20<?php
21/*  Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
22    Description: Makes directory
23*/
24
25$context = stream_context_create();
26
27$file_path = dirname(__FILE__);
28
29echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
30var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true, $context) );
31var_dump( rmdir("$file_path/mkdir_variation2/test/", $context) );
32
33echo "\n*** Testing rmdir() on a non-empty directory ***\n";
34var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true) );
35var_dump( rmdir("$file_path/mkdir_variation2/") );
36
37echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
38var_dump( mkdir("$file_path/temp".chr(0)."/") );
39var_dump( rmdir("$file_path/temp".chr(0)."/") );
40
41echo "\n*** Testing mkdir() with miscelleneous input ***\n";
42/* changing mode of mkdir to prevent creating sub-directory under it */
43var_dump( chmod("$file_path/mkdir_variation2/", 0000) );
44/* creating sub-directory test1 under mkdir, expected: false */
45var_dump( mkdir("$file_path/mkdir_variation2/test1", 0777, true) );
46var_dump( chmod("$file_path/mkdir_variation2/", 0777) );  // chmod to enable removing test1 directory
47
48echo "Done\n";
49?>
50--CLEAN--
51<?php
52rmdir(dirname(__FILE__)."/mkdir_variation2/test/");
53rmdir(dirname(__FILE__)."/mkdir_variation2/");
54?>
55--EXPECTF--
56*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
57bool(true)
58bool(true)
59
60*** Testing rmdir() on a non-empty directory ***
61bool(true)
62
63Warning: rmdir(%s/mkdir_variation2/): %s on line %d
64bool(false)
65
66*** Testing mkdir() and rmdir() for binary safe functionality ***
67
68Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
69bool(false)
70
71Warning: rmdir() expects parameter 1 to be a valid path, string given in %s on line %d
72bool(false)
73
74*** Testing mkdir() with miscelleneous input ***
75bool(true)
76
77Warning: mkdir(): Permission denied in %s on line %d
78bool(false)
79bool(true)
80Done
81