From f58e9439daddcd37aad6555a5860e39771191798 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 18 Sep 2023 13:56:30 +0100 Subject: [PATCH] Change detection of /etc/shadow This is a work-around for file_exists() not working when infection/include-interceptor is loaded. --- test/ComposerRequireCheckerTest/JsonLoaderTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/ComposerRequireCheckerTest/JsonLoaderTest.php b/test/ComposerRequireCheckerTest/JsonLoaderTest.php index 05d4b6c1..1c4b8034 100644 --- a/test/ComposerRequireCheckerTest/JsonLoaderTest.php +++ b/test/ComposerRequireCheckerTest/JsonLoaderTest.php @@ -9,7 +9,9 @@ use ComposerRequireChecker\JsonLoader; use PHPUnit\Framework\TestCase; -use function file_exists; +use function is_readable; + +use const PHP_OS_FAMILY; /** @covers \ComposerRequireChecker\JsonLoader */ final class JsonLoaderTest extends TestCase @@ -35,8 +37,8 @@ public function testHasErrorWithInvalidFile(): void public function testHasErrorWithUnreadableFile(): void { $path = '/etc/shadow'; - if (! file_exists($path)) { - $this->markTestSkipped('This system does not have ' . $path); + if (PHP_OS_FAMILY !== 'Linux' || is_readable($path)) { + $this->markTestSkipped('This test relies on ' . $path . ' existing, but being unreadable.'); } $this->expectException(NotReadable::class);