Passed
Push — master ( c86ace...13d1a4 )
by Akmal
01:06
created

UriTest::testMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
rs 9.9666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace OpenEngine\Mika\Core\Components\Http\Message\Uri\Tests;
4
5
use OpenEngine\Mika\Core\Components\Http\Message\Uri\Uri;
6
use PHPUnit\Framework\TestCase;
7
8
class UriTest extends TestCase
9
{
10
    const URI = 'http://username:password@hostname:9090/path?arg=value#anchor';
11
12
    public function testBase(): void
13
    {
14
        $uri = new Uri(self::URI);
15
        $this->assertStringEndsWith(self::URI, $uri->__toString());
16
    }
17
18
    public function testClone(): void
19
    {
20
        $uri = new Uri(self::URI);
21
        $new = $uri
22
            ->withScheme('hTtPS')
23
            ->withUserInfo('john', 'doe')
24
            ->withHost('localhost')
25
            ->withPort(443)
26
            ->withPath('main/index.php')
27
            ->withQuery('foo=bar&baz=baz2')
28
            ->withFragment('fragment');
29
30
        $this->assertStringEndsWith('https://john:doe@localhost/main/index.php?foo=bar&baz=baz2#fragment',
31
            $new->__toString());
32
    }
33
34
    public function testMethods(): void
35
    {
36
        $uri = new Uri(self::URI);
37
        $this->assertStringEndsWith('http', $uri->getScheme());
38
        $this->assertStringEndsWith('username:password@hostname:9090', $uri->getAuthority());
39
        $this->assertStringEndsWith('username:password', $uri->getUserInfo());
40
        $this->assertStringEndsWith('hostname', $uri->getHost());
41
        $this->equalTo(9090, $uri->getPort());
42
        $this->assertStringEndsWith('path', $uri->getPath());
43
        $this->assertStringEndsWith('arg=value', $uri->getQuery());
44
        $this->assertStringEndsWith('anchor', $uri->getFragment());
45
    }
46
}
47