Skip to content

Commit 182a782

Browse files
SanderMullerclaude
authored andcommitted
Skip the read-only directory assertion when the tests run as root
Root can write to a directory with mode 0500, so is_writable() is true there. The Docker jobs run the tests as root. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent eda5320 commit 182a782

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎tests/PHPStan/Process/Restart/OpcacheSettingsTest.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
use function array_keys;
99
use function chmod;
1010
use function fileowner;
11+
use function function_exists;
1112
use function is_dir;
1213
use function is_link;
1314
use function mkdir;
15+
use function posix_geteuid;
1416
use function rmdir;
1517
use function scandir;
1618
use function symlink;
@@ -190,7 +192,10 @@ public function testIsPrivateDirectory(): void
190192
$this->assertFalse(OpcacheSettings::isPrivateDirectory($base . '/shared', $userId));
191193

192194
mkdir($base . '/readonly', 0500);
193-
$this->assertFalse(OpcacheSettings::isPrivateDirectory($base . '/readonly', $userId));
195+
// root can write to any directory, so is_writable() does not see the mode
196+
if (function_exists('posix_geteuid') && posix_geteuid() !== 0) {
197+
$this->assertFalse(OpcacheSettings::isPrivateDirectory($base . '/readonly', $userId));
198+
}
194199
chmod($base . '/readonly', 0700);
195200

196201
symlink($base . '/private', $base . '/link');

0 commit comments

Comments
 (0)