43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Orbit\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Orbit\Request;
|
|
|
|
final class RequestTest extends TestCase
|
|
{
|
|
public function testConstruct(): void
|
|
{
|
|
$request = new Request('foo');
|
|
$this->assertInstanceOf(Request::class, $request);
|
|
$this->assertSame('foo', $request->url);
|
|
$this->assertSame('foo', $request->path);
|
|
}
|
|
|
|
public function testConstructFullUrl(): void
|
|
{
|
|
$url = 'https://bob:haha@null.com:7000/x/y/z.bar?q=2&b=3#ok';
|
|
$request = new Request($url);
|
|
$this->assertInstanceOf(Request::class, $request);
|
|
$this->assertSame($url, $request->url);
|
|
$this->assertSame('https', $request->scheme);
|
|
$this->assertSame('bob', $request->user);
|
|
$this->assertSame('haha', $request->pass);
|
|
$this->assertSame('null.com', $request->host);
|
|
$this->assertSame('7000', $request->port);
|
|
$this->assertSame('/x/y/z.bar', $request->path);
|
|
$this->assertSame('q=2&b=3', $request->query);
|
|
$this->assertSame('ok', $request->fragment);
|
|
}
|
|
|
|
public function testGetUrlAppendPath(): void
|
|
{
|
|
$url = 'gemini://null.com/sub/?real=1';
|
|
$request = new Request($url);
|
|
$updated = $request->getUrlAppendPath('addition');
|
|
$this->assertSame('gemini://null.com/sub/addition?real=1', $updated);
|
|
}
|
|
}
|