diff --git a/tests/system/HTTP/SiteURITest.php b/tests/system/HTTP/SiteURITest.php index 807ac03f6ced..e00c65b0c89e 100644 --- a/tests/system/HTTP/SiteURITest.php +++ b/tests/system/HTTP/SiteURITest.php @@ -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(); @@ -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();