mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
6a74cf96a1
* Allow backslash after drive name
Before, paths like `C:/path/to/something` were considered absolute, but
`C:\path/to/something` were not
Refs vimeo/psalm#1913
* Revert "Mark testPluginFilenameCanBeAbsolute incomplete on Windows (#1914)"
This reverts commit 210ac39d00
.
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
namespace Psalm\Tests;
|
|
|
|
use function Psalm\isAbsolutePath;
|
|
|
|
class IsAbsolutePathTest extends TestCase
|
|
{
|
|
/**
|
|
* @param string $path
|
|
* @param bool $expected
|
|
*
|
|
* @return void
|
|
*
|
|
* @dataProvider providerForTestIsAbsolutePath
|
|
*/
|
|
public function testIsAbsolutePath($path, $expected)
|
|
{
|
|
self::assertSame($expected, isAbsolutePath($path));
|
|
}
|
|
|
|
/**
|
|
* @return array<int, array{0:string, 1:bool}>
|
|
*/
|
|
public function providerForTestIsAbsolutePath()
|
|
{
|
|
return [
|
|
['/path/to/something', true],
|
|
['/path/to/something/file.php', true],
|
|
['relative/path/to/something', false],
|
|
['relative/path/to/something/file.php', false],
|
|
['c:/path/to/something', true],
|
|
['C:\path\to\something', true],
|
|
['C:\path/to\something', true],
|
|
['\path\to\something', true],
|
|
['C:\path/to\..\..\something', true],
|
|
['file://c:/path/to/something', true],
|
|
['zlib://c:/path/to/something', true],
|
|
];
|
|
}
|
|
}
|