Annotation of embedaddon/php/ext/standard/tests/file/mkdir_rmdir_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test mkdir() and rmdir() functions: usage variations - misc.
! 3: --SKIPIF--
! 4: <?php
! 5: if (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');
! 11: fclose($fp);
! 12: if(fileowner($filename) == 0) {
! 13: unlink ($filename);
! 14: die('skip cannot be run as root');
! 15: }
! 16:
! 17: unlink($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:
! 29: echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
! 30: var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true, $context) );
! 31: var_dump( rmdir("$file_path/mkdir_variation2/test/", $context) );
! 32:
! 33: echo "\n*** Testing rmdir() on a non-empty directory ***\n";
! 34: var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true) );
! 35: var_dump( rmdir("$file_path/mkdir_variation2/") );
! 36:
! 37: echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
! 38: var_dump( mkdir("$file_path/temp".chr(0)."/") );
! 39: var_dump( rmdir("$file_path/temp".chr(0)."/") );
! 40:
! 41: echo "\n*** Testing mkdir() with miscelleneous input ***\n";
! 42: /* changing mode of mkdir to prevent creating sub-directory under it */
! 43: var_dump( chmod("$file_path/mkdir_variation2/", 0000) );
! 44: /* creating sub-directory test1 under mkdir, expected: false */
! 45: var_dump( mkdir("$file_path/mkdir_variation2/test1", 0777, true) );
! 46: var_dump( chmod("$file_path/mkdir_variation2/", 0777) ); // chmod to enable removing test1 directory
! 47:
! 48: echo "Done\n";
! 49: ?>
! 50: --CLEAN--
! 51: <?php
! 52: rmdir(dirname(__FILE__)."/mkdir_variation2/test/");
! 53: rmdir(dirname(__FILE__)."/mkdir_variation2/");
! 54: ?>
! 55: --EXPECTF--
! 56: *** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
! 57: bool(true)
! 58: bool(true)
! 59:
! 60: *** Testing rmdir() on a non-empty directory ***
! 61: bool(true)
! 62:
! 63: Warning: rmdir(%s/mkdir_variation2/): %s on line %d
! 64: bool(false)
! 65:
! 66: *** Testing mkdir() and rmdir() for binary safe functionality ***
! 67: bool(false)
! 68: bool(false)
! 69:
! 70: *** Testing mkdir() with miscelleneous input ***
! 71: bool(true)
! 72:
! 73: Warning: mkdir(): Permission denied in %sfile/mkdir_rmdir_variation2.php on line %d
! 74: bool(false)
! 75: bool(true)
! 76: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>