Skip to content

Commit 2eddd33

Browse files
author
Mikhail Galanin
committed
Added test for errorlog mode setting
1 parent e193271 commit 2eddd33

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/basic/errorlog_permission.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Check permissions for created errorlog file
3+
--SKIPIF--
4+
<?php
5+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
6+
die("skip this test on windows");
7+
}
8+
?>
9+
--INI--
10+
error_log=error_permissions_test.log
11+
error_log_mode=0600
12+
--FILE--
13+
<?php
14+
15+
const LOG_FILENAME='error_permissions_test.log';
16+
17+
try {
18+
if (file_exists(LOG_FILENAME)) {
19+
unlink(LOG_FILENAME);
20+
}
21+
$oldMask = umask(0000);
22+
23+
error_log("hello world");
24+
25+
assert(file_exists(LOG_FILENAME));
26+
27+
printf("got permissions=%o\n", fileperms(LOG_FILENAME) & 0777);
28+
printf("errorlog contents\n%s", file_get_contents(LOG_FILENAME));
29+
30+
umask($oldMask);
31+
} finally {
32+
unlink(LOG_FILENAME);
33+
}
34+
?>
35+
--EXPECTF--
36+
got permissions=600
37+
errorlog contents
38+
[%d-%s-%d %d:%d:%d %s] hello world

0 commit comments

Comments
 (0)