Skip to content

Commit

Permalink
Added some more tests (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Apr 9, 2023
1 parent c06c9e0 commit c3c62f4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ public function testCookieParams()

public function testQueryParams()
{
$request1 = new ServerRequest('GET', '/?foo=bar');
$request0 = new ServerRequest('GET', '/');
$this->assertEmpty($request0->getQueryParams());

$request1 = new ServerRequest('GET', '/?foo=bar');
$params = ['name' => 'value'];

$request2 = $request1->withQueryParams($params);

$this->assertNotSame($request2, $request1);
Expand Down
22 changes: 22 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ public function testParsesProvidedUri()
}

public function testCanTransformAndRetrievePartsIndividually()
{
$uri = (new Uri())
->withScheme('https')
->withUserInfo('user', 'pass')
->withHost('example.com')
->withPort(8080)
->withPath('/path/123')
->withQuery('q=abc')
->withFragment('test');

$this->assertSame('https', $uri->getScheme());
$this->assertSame('user:pass@example.com:8080', $uri->getAuthority());
$this->assertSame('user:pass', $uri->getUserInfo());
$this->assertSame('example.com', $uri->getHost());
$this->assertSame(8080, $uri->getPort());
$this->assertSame('/path/123', $uri->getPath());
$this->assertSame('q=abc', $uri->getQuery());
$this->assertSame('test', $uri->getFragment());
$this->assertSame('https://user:pass@example.com:8080/path/123?q=abc#test', (string) $uri);
}

public function testSupportsUrlEncodedValues()
{
$uri = (new Uri())
->withScheme('https')
Expand Down

0 comments on commit c3c62f4

Please sign in to comment.