readdir_variation5.phpt [plain text]
--TEST--
Test readdir() function : usage variations - different permissions
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
$filename = dirname(__FILE__)."/readdir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
?>
--FILE--
<?php
echo "*** Testing readdir() : usage variations ***\n";
$dir_path = dirname(__FILE__) . "/readdir_variation5";
mkdir($dir_path);
$permission_values = array(
0477, 0677,
0444, 0666,
0400, 0600,
0470, 0407,
0670, 0607 );
$iterator = 1;
foreach($permission_values as $perm) {
echo "\n-- Iteration $iterator --\n";
if (is_dir($dir_path)) {
chmod ($dir_path, 0777); rmdir ($dir_path);
}
mkdir($dir_path);
var_dump( chmod($dir_path, $perm) );
var_dump($dh = opendir($dir_path));
echo "-- Calling readdir() --\n";
var_dump(readdir($dh));
closedir($dh);
$iterator++;
}
?>
===DONE===
--CLEAN--
<?php
$dir_path = dirname(__FILE__) . "/readdir_variation5";
rmdir($dir_path);
?>
--EXPECTF--
*** Testing readdir() : usage variations ***
-- Iteration 1 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 2 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 3 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 4 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 5 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 6 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 7 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 8 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 9 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
-- Iteration 10 --
bool(true)
resource(%d) of type (stream)
-- Calling readdir() --
string(%d) "%s"
===DONE===