Skip to content

Commit 22cfe96

Browse files
aazsamirbrendt
andauthored
test(core): cover normalize_path inside phar (#1685)
Co-authored-by: Brent Roose <[email protected]>
1 parent 87b2f7b commit 22cfe96

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

packages/support/tests/Filesystem/UnixFunctionsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,4 +698,22 @@ public function test_delete_file_for_invalid_symlink(): void
698698
$this->assertFalse(is_file($link));
699699
$this->assertFalse(is_link($link));
700700
}
701+
702+
public function test_normalize_path_in_phar(): void
703+
{
704+
if (\Phar::canWrite() === false) {
705+
$this->markTestSkipped('phar.readonly is enabled in php.ini.');
706+
}
707+
708+
$pharFile = $this->fixtures . '/phar.phar';
709+
$phar = new \Phar($pharFile, 0, 'phar.phar');
710+
$phar->addFile(__DIR__ . '/../../src/Filesystem/functions.php', 'functions.php');
711+
$phar->addFile(__DIR__ . '/../Fixtures/Phar/normalize_path.php', 'index.php');
712+
$phar->createDefaultStub('index.php');
713+
714+
$output = shell_exec('php ' . $pharFile);
715+
716+
$this->assertIsString($output);
717+
$this->assertStringStartsWith('phar://', $output);
718+
}
701719
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once 'phar://phar.phar/functions.php';
6+
7+
echo \Tempest\Support\Filesystem\normalize_path(__DIR__);

packages/support/tests/Path/FunctionsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@ public static function paths(): Generator
189189
'paths' => ['foo\\', '\\'],
190190
'expected' => 'foo/',
191191
];
192+
193+
yield 'phar prefix' => [
194+
'paths' => ['phar:///home/user/file.php'],
195+
'expected' => 'phar:///home/user/file.php',
196+
];
192197
}
193198
}

0 commit comments

Comments
 (0)