This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
UriParserTest.php
90 lines (65 loc) · 2.05 KB
/
UriParserTest.php
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace Sunrise\Uri\Tests;
use PHPUnit\Framework\TestCase;
use Sunrise\Uri\UriParser;
use Sunrise\Uri\Exception\InvalidUriException;
class UriParserTest extends TestCase
{
public const TEST_URI = 'scheme://user:pass@host:3000/path?query#fragment';
public function testConstructor()
{
$uri = new UriParser(self::TEST_URI);
$this->assertInstanceOf(UriParser::class, $uri);
}
public function testConstructorWithInvalidString()
{
$this->expectException(InvalidUriException::class);
$this->expectExceptionMessage('URI must be a string');
$uri = new UriParser(1234456);
}
public function testGetScheme()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('scheme', $uri->getScheme()->present());
}
public function testGetUser()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('user', $uri->getUser()->present());
}
public function testGetPass()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('pass', $uri->getPass()->present());
}
public function testGetHost()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('host', $uri->getHost()->present());
}
public function testGetPort()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame(3000, $uri->getPort()->present());
}
public function testGetPath()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('/path', $uri->getPath()->present());
}
public function testGetQuery()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('query', $uri->getQuery()->present());
}
public function testGetFragment()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('fragment', $uri->getFragment()->present());
}
public function testGetUserInfo()
{
$uri = new UriParser(self::TEST_URI);
$this->assertSame('user:pass', $uri->getUserInfo()->present());
}
}