getScheme()); self::assertEquals('www.google.com', $obj->getHost()); self::assertEquals(80, $obj->getPort()); self::assertEquals('', $obj->getPass()); self::assertEquals('', $obj->getUser()); self::assertEquals('https://www.google.com', $obj->getBase()); self::assertEquals($uri, $obj->__toString()); self::assertEquals('www.google.com:80', $obj->getAuthority()); self::assertEquals('', $obj->getUserInfo()); } public function testRootPath() : void { $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('', $obj->getRootPath()); $obj->setRootPath('a'); self::assertEquals('a', $obj->getRootPath()); } public function testPathOffset() : void { $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals(0, $obj->getPathOffset()); $obj->setPathOffset(2); self::assertEquals(2, $obj->getPathOffset()); } public function testSubdmonain() : void { $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('www', $obj->getSubdomain()); $obj = new Http('https://google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('', $obj->getSubdomain()); $obj = new Http('https://test.www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('test.www', $obj->getSubdomain()); } public function testQueryData() : void { $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('para1=abc¶2=2', $obj->getQuery()); self::assertEquals(['para1' => 'abc', 'para2' => '2'], $obj->getQueryArray()); self::assertEquals('2', $obj->getQuery('para2')); self::assertEquals('frag', $obj->getFragment()); } public function testPathData() : void { $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('/test/path', $obj->getPath()); self::assertEquals('/test/path?para1=abc¶2=2', $obj->getRoute()); self::assertEquals('test', $obj->getPathElement(0)); } }