You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Arokettu\Path\Tests;
|
|
|
|
use Arokettu\Path\PathUtils;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class PathUtilsTest extends TestCase
|
|
{
|
|
public function testMakeRelative(): void
|
|
{
|
|
self::assertEquals(
|
|
'../../.config/composer',
|
|
PathUtils::makeRelativePath(
|
|
'/home/arokettu/tmp/test',
|
|
'/home/arokettu/.config/composer',
|
|
),
|
|
);
|
|
|
|
self::assertEquals(
|
|
'..\..\AppData\Roaming',
|
|
PathUtils::makeRelativePath(
|
|
'C:\Users\Arokettu\tmp\test',
|
|
'C:\Users\Arokettu\AppData\Roaming',
|
|
),
|
|
);
|
|
}
|
|
|
|
public function testResolveRelative(): void
|
|
{
|
|
// any, absolute
|
|
self::assertEquals(
|
|
'/home/arokettu/.config/composer',
|
|
PathUtils::resolveRelativePath(
|
|
'/home/arokettu/tmp/test',
|
|
'/home/arokettu/.config/composer',
|
|
),
|
|
);
|
|
|
|
// absolute, relative
|
|
self::assertEquals(
|
|
'/home/arokettu/.config/composer',
|
|
PathUtils::resolveRelativePath(
|
|
'/home/arokettu/tmp/test',
|
|
'../../.config/composer',
|
|
),
|
|
);
|
|
|
|
// relative, relative
|
|
self::assertEquals(
|
|
'.config/composer',
|
|
PathUtils::resolveRelativePath(
|
|
'./tmp/test',
|
|
'../../.config/composer',
|
|
),
|
|
);
|
|
}
|
|
}
|