for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Spiral Framework package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Spiral\Tests\Files;
use Spiral\Files\Files;
class ConversionTest extends TestCase
{
public function testNormalizeFilePath(): void
$files = new Files();
$this->assertSame('/abc/file.name', $files->normalizePath('/abc\\file.name'));
$this->assertSame('/abc/file.name', $files->normalizePath('\\abc//file.name'));
}
public function testNormalizeDirectoryPath(): void
$this->assertSame('/abc/dir/', $files->normalizePath('\\abc/dir', true));
$this->assertSame('/abc/dir/', $files->normalizePath('\\abc//dir', true));
public function testRelativePath(): void
$this->assertSame(
'some-filename.txt',
$files->relativePath('/abc/some-filename.txt', '/abc')
);
'../some-filename.txt',
$files->relativePath('/abc/../some-filename.txt', '/abc')
'../../some-filename.txt',
$files->relativePath('/abc/../../some-filename.txt', '/abc')
'./some-filename.txt',
$files->relativePath('/abc/some-filename.txt', '/abc/..')
$files->relativePath('/abc/some-filename.txt', '/abc/../..')