Skip to content

Commit

Permalink
test: add test cases for path starting with slash
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 20, 2023
1 parent d1c14c9 commit 7699c85
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/system/HTTP/SiteURITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ public function testConstructorRelativePath()
$this->assertSame('/index.php/one/two', $uri->getPath());
}

public function testConstructorRelativePathStartWithSlash()
{
$config = new App();

$uri = new SiteURI($config, '/one/two');

$this->assertSame('http://example.com/index.php/one/two', (string) $uri);
$this->assertSame('one/two', $uri->getRoutePath());
$this->assertSame('/index.php/one/two', $uri->getPath());
}

public function testConstructorRelativePathWithQuery()
{
$config = new App();
Expand Down Expand Up @@ -190,6 +201,22 @@ public function testSetPath()
$this->assertSame(2, $uri->getTotalSegments());
}

public function testSetPathStartWithSlash()
{
$config = new App();

$uri = new SiteURI($config);

$uri->setPath('/test/method');

$this->assertSame('http://example.com/index.php/test/method', (string) $uri);
$this->assertSame('test/method', $uri->getRoutePath());
$this->assertSame('/index.php/test/method', $uri->getPath());
$this->assertSame(['test', 'method'], $uri->getSegments());
$this->assertSame('test', $uri->getSegment(1));
$this->assertSame(2, $uri->getTotalSegments());
}

public function testSetPathSubfolder()
{
$config = new App();
Expand Down

0 comments on commit 7699c85

Please sign in to comment.