Repository navigation
Expand file tree
/
Copy pathTextDocumentUriTest.php
More file actions
68 lines (56 loc) · 2.01 KB
/
Copy pathTextDocumentUriTest.php
File metadata and controls
68 lines (56 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Phpactor\TextDocument\Tests\Unit;
use PHPUnit\Framework\TestCase;
use Phpactor\TextDocument\Exception\InvalidUriException;
use Phpactor\TextDocument\TextDocumentUri;
class TextDocumentUriTest extends TestCase
{
public function testCreate(): void
{
$uri = TextDocumentUri::fromString('file://' . __FILE__);
$this->assertEquals('file://' . __FILE__, (string) $uri);
}
public function testNormalizesToFileScheme(): void
{
$uri = TextDocumentUri::fromString(__FILE__);
$this->assertEquals('file://' . __FILE__, (string) $uri);
}
public function testExceptionOnNonAbsolutePath(): void
{
$this->expectException(InvalidUriException::class);
TextDocumentUri::fromString('i is relative');
}
public function testExceptionOnInvalidUri(): void
{
$this->expectException(InvalidUriException::class);
$this->expectExceptionMessage('not parse');
TextDocumentUri::fromString('no:///this:isnot/ && !');
}
public function testExceptionOnNoPath(): void
{
$this->expectException(InvalidUriException::class);
$this->expectExceptionMessage('has no path');
TextDocumentUri::fromString('file://foo');
}
public function testFromPath(): void
{
$uri = TextDocumentUri::fromString('/foobar');
$this->assertEquals('file:///foobar', $uri->__toString());
}
public function testFromHttpUri(): void
{
$this->expectException(InvalidUriException::class);
$this->expectExceptionMessage('Only "file://" scheme is supported, got "http"');
$uri = TextDocumentUri::fromString('http://foobar/foobar');
}
public function testReturnsPath(): void
{
$uri = TextDocumentUri::fromString('file://' . __FILE__);
$this->assertEquals(__FILE__, $uri->path());
}
public function testScheme(): void
{
$uri = TextDocumentUri::fromString('file://' . __FILE__);
$this->assertEquals('file', $uri->scheme());
}
}