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

RequestTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3
1
<?php declare(strict_types=1);
2
3
namespace OpenEngine\Mika\Core\Components\Http\Message\Request\Tests;
4
5
use OpenEngine\Mika\Core\Components\Http\Message\Request\Request;
6
use OpenEngine\Mika\Core\Components\Http\Message\Request\RequestFactory;
7
use OpenEngine\Mika\Core\Components\Http\Message\Uri\UriFactory;
8
use PHPUnit\Framework\TestCase;
9
10
class RequestTest extends TestCase
11
{
12
    public function testFactory(): void
13
    {
14
        $request = (new RequestFactory())->createRequest('get', (new UriFactory)->createUri('http://localhost:8021'));
15
        self::assertStringEndsWith('GET', $request->getMethod());
16
        self::assertArrayHasKey('host', $request->getHeaders());
17
        self::assertStringEndsWith('localhost', $request->getHeaderLine('host'));
18
    }
19
20
    public function testTarget(): void
21
    {
22
        $request = new Request((new UriFactory)->createUri('http://localhost:8021/test/index.php?foo=bar'));
23
        self::assertStringEndsWith('/test/index.php?foo=bar', $request->getRequestTarget());
24
        self::assertStringEndsWith('/foo', $request->withRequestTarget('/foo')->getRequestTarget());
25
    }
26
27
    public function testBase(): void
28
    {
29
        $request = new Request((new UriFactory)->createUri('http://localhost:8021/test/index.php?foo=bar'));
30
        self::assertStringEndsWith('/test/index.php?foo=bar', $request->getRequestTarget());
31
    }
32
}
33