dir_variation3.phpt [plain text]
--TEST--
Test dir() function : usage variations - different directory permissions
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
$filename = dirname(__FILE__)."/dir_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 dir() : different directory permissions ***";
$file_path = dirname(__FILE__);
$dir_path = $file_path."/dir_variation3";
@mkdir($dir_path);
$permission_values = array(
0477, 0677,
0444, 0666,
0400, 0600,
0470, 0407,
0670, 0607 );
for($count = 0; $count < count($permission_values); $count++) {
echo "\n-- Iteration ".($count + 1)." --\n";
$file_path = dirname(__FILE__);
$dir_path = $file_path."/dir_variation3";
@chmod ($dir_path, 0777); @rmdir ($dir_path);
@mkdir($dir_path);
var_dump( chmod($dir_path, $permission_values[$count]) );
$d = dir($dir_path);
var_dump($d);
echo "-- reading contents --\n";
var_dump($d->read());
$d->close();
}
echo "Done";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
$dir_path = $file_path."/dir_variation3";
rmdir($dir_path);
?>
--EXPECTF--
*** Testing dir() : different directory permissions ***
-- Iteration 1 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 2 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 3 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 4 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 5 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 6 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 7 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 8 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 9 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
-- Iteration 10 --
bool(true)
object(Directory)#%d (2) {
["path"]=>
string(%d) "%s/dir_variation3"
["handle"]=>
resource(%d) of type (stream)
}
-- reading contents --
string(%d) "%s"
Done