Skip to content

Commit 7699c85

Browse files
committed
test: add test cases for path starting with slash
1 parent d1c14c9 commit 7699c85

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/system/HTTP/SiteURITest.php

+27
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public function testConstructorRelativePath()
5050
$this->assertSame('/index.php/one/two', $uri->getPath());
5151
}
5252

53+
public function testConstructorRelativePathStartWithSlash()
54+
{
55+
$config = new App();
56+
57+
$uri = new SiteURI($config, '/one/two');
58+
59+
$this->assertSame('http://example.com/index.php/one/two', (string) $uri);
60+
$this->assertSame('one/two', $uri->getRoutePath());
61+
$this->assertSame('/index.php/one/two', $uri->getPath());
62+
}
63+
5364
public function testConstructorRelativePathWithQuery()
5465
{
5566
$config = new App();
@@ -190,6 +201,22 @@ public function testSetPath()
190201
$this->assertSame(2, $uri->getTotalSegments());
191202
}
192203

204+
public function testSetPathStartWithSlash()
205+
{
206+
$config = new App();
207+
208+
$uri = new SiteURI($config);
209+
210+
$uri->setPath('/test/method');
211+
212+
$this->assertSame('http://example.com/index.php/test/method', (string) $uri);
213+
$this->assertSame('test/method', $uri->getRoutePath());
214+
$this->assertSame('/index.php/test/method', $uri->getPath());
215+
$this->assertSame(['test', 'method'], $uri->getSegments());
216+
$this->assertSame('test', $uri->getSegment(1));
217+
$this->assertSame(2, $uri->getTotalSegments());
218+
}
219+
193220
public function testSetPathSubfolder()
194221
{
195222
$config = new App();

0 commit comments

Comments
 (0)