From e68f6c60dd6470c83fa5e757abb9f7820c74440a Mon Sep 17 00:00:00 2001 From: albertlast Date: Mon, 31 Aug 2026 17:26:07 +0200 Subject: [PATCH] Anchors the canonical path test to the root the platform actually uses An absolute path is rooted differently on each platform: a leading separator on POSIX, a drive letter on Windows. Naming the root in the path under test keeps the assertion about the dot segments rather than about the machine the suite happens to run on. Signed-off-by: albertlast --- tests/Unit/SapiTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Unit/SapiTest.php b/tests/Unit/SapiTest.php index 8e5d3875fe..501135d849 100644 --- a/tests/Unit/SapiTest.php +++ b/tests/Unit/SapiTest.php @@ -18,8 +18,14 @@ class SapiTest extends TestCase public function testCanonicalPathResolvesDotSegments(): void { - $this->assertSame('/a/c', Sapi::canonicalPath('/a/./b/../c', false, false)); - $this->assertSame('/a', Sapi::canonicalPath('/a/b/..', false, false)); + // The root of an absolute path is a drive letter on Windows and nothing + // at all on POSIX, so name it here rather than let the current drive + // decide. Everything after it is the same on both. + $root = DIRECTORY_SEPARATOR === '/' ? '' : 'C:'; + $sep = DIRECTORY_SEPARATOR; + + $this->assertSame($root . $sep . 'a' . $sep . 'c', Sapi::canonicalPath($root . '/a/./b/../c', false, false)); + $this->assertSame($root . $sep . 'a', Sapi::canonicalPath($root . '/a/b/..', false, false)); } public function testTheSuiteRunsOnTheCommandLine(): void