Page MenuHomeDevCentral

D2278.id5737.diff
No OneTemporary

D2278.id5737.diff

diff --git a/tests/Reflection/CodeFileTest.php b/tests/Reflection/CodeFileTest.php
--- a/tests/Reflection/CodeFileTest.php
+++ b/tests/Reflection/CodeFileTest.php
@@ -36,6 +36,12 @@
}
public function testCanBeIncludedWhenFileModeForbidsReading () : void {
+ if (self::runsAsRoot()) {
+ $this->markTestSkipped(
+ "This test requires non-root access to run properly."
+ );
+ }
+
$file = $this->getNonReadableFile();
$this->assertFalse(CodeFile::From($file)->canBeIncluded());
@@ -55,6 +61,12 @@
}
public function testIsReadableWhenFileModeForbidsReading () : void {
+ if (self::runsAsRoot()) {
+ $this->markTestSkipped(
+ "This test requires non-root access to run properly."
+ );
+ }
+
$file = $this->getNonReadableFile();
$this->assertFalse(CodeFile::From($file)->isReadable());
@@ -62,6 +74,20 @@
unlink($file);
}
+ private static function isWindows () : bool {
+ return PHP_OS === 'CYGWIN'
+ || strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
+ }
+
+ private static function runsAsRoot () : bool {
+ if (self::isWindows()) {
+ exec("net session >nul 2>&1", $_, $exitCode);
+ return $exitCode === 0;
+ }
+
+ return trim(shell_exec('id -u')) === '0';
+ }
+
private function getNonReadableFile () : string {
$file = tempnam(sys_get_temp_dir(), "testCodeFile");
chmod($file, 0);

File Metadata

Mime Type
text/plain
Expires
Tue, May 6, 05:01 (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2634879
Default Alt Text
D2278.id5737.diff (1 KB)

Event Timeline