1
0
Fork 0
get-installer-bootstrap/tests/Service/PathNormalizerTest.php
2026-05-05 09:50:55 +02:00

48 lines
1.3 KiB
PHP

<?php
namespace App\Tests\Service;
use App\Service\PathNormalizer;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
final class PathNormalizerTest extends TestCase
{
private PathNormalizer $normalizer;
protected function setUp(): void
{
$this->normalizer = new PathNormalizer();
}
public function testPublicPathIsNormalized(): void
{
self::assertSame('mcp/graylog/install.sh', $this->normalizer->publicPath('/mcp/graylog/install.sh'));
}
public function testPublicPathMustEndWithShellExtension(): void
{
$this->expectException(InvalidArgumentException::class);
$this->normalizer->publicPath('mcp/graylog/install.txt');
}
public function testPublicPathRejectsTraversal(): void
{
$this->expectException(InvalidArgumentException::class);
$this->normalizer->publicPath('mcp/../install.sh');
}
public function testRepositoryPathAllowsNestedFileWithoutShellRequirement(): void
{
self::assertSame('scripts/install', $this->normalizer->repositoryPath('/scripts/install'));
}
public function testRepositoryPathRejectsTraversal(): void
{
$this->expectException(InvalidArgumentException::class);
$this->normalizer->repositoryPath('../install.sh');
}
}