From b99cc9558e591bda0a0841a4b57e066f1f8fd8b4 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Sat, 17 Nov 2018 15:22:54 -0200 Subject: [PATCH] Test URI segments --- tests/system/HTTP/URITest.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/system/HTTP/URITest.php b/tests/system/HTTP/URITest.php index 6d06fc65d739..795696b00207 100644 --- a/tests/system/HTTP/URITest.php +++ b/tests/system/HTTP/URITest.php @@ -742,6 +742,36 @@ public function testSetSegment() $this->assertEquals('foo/banana/baz', $uri->getPath()); } + //-------------------------------------------------------------------- + + public function testSetSegmentFallback() + { + $base = 'http://example.com'; + + $uri = new URI($base); + $uri->setSegment(1, 'first'); + $uri->setSegment(3, 'third'); + + $this->assertEquals('first/third', $uri->getPath()); + + $uri->setSegment(2, 'second'); + + $this->assertEquals('first/second', $uri->getPath()); + + $uri->setSegment(3, 'third'); + + $this->assertEquals('first/second/third', $uri->getPath()); + + $uri->setSegment(5, 'fifth'); + + $this->assertEquals('first/second/third/fifth', $uri->getPath()); + + // sixth or seventh was not set + $this->expectException(HTTPException::class); + + $uri->setSegment(8, 'eighth'); + } + public function testSetBadSegment() { $this->expectException(HTTPException::class);