function testCreate() { $str = 'http://*****:*****@localhost:81/test.php/test?foo=bar#23'; $uri = new lmbUri($str); $this->assertEqual($uri->getProtocol(), 'http'); $this->assertEqual($uri->getHost(), 'localhost'); $this->assertEqual($uri->getUser(), 'admin'); $this->assertEqual($uri->getPassword(), 'test'); $this->assertEqual($uri->getPort(), '81'); $this->assertEqual($uri->getAnchor(), '23'); $this->assertEqual($uri->getQueryItem('foo'), 'bar'); $this->assertEqual($uri->countQueryItems(), 1); $this->assertEqual($uri->getPath(), '/test.php/test'); $this->assertEqual($uri->countPath(), 3); $this->assertEqual($uri->getPathElements(), array('', 'test.php', 'test')); $this->assertEqual($uri->getPathElement(0), ''); $this->assertEqual($uri->getPathElement(1), 'test.php'); $this->assertEqual($uri->getPathElement(2), 'test'); }
protected function _getHttpBasePathOffsetLevel($uri) { if (!$this->path_offset) { return 0; } $base_path_uri = new lmbUri(rtrim($this->base_path, '/')); $base_path_uri->normalizePath(); $level = 1; while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) { $level++; } return $level; }
protected function _getHttpBasePathOffsetLevel($uri) { if (!lmb_env_get('LIMB_HTTP_OFFSET_PATH')) { return 0; } $base_path = $uri->toString(array('protocol', 'user', 'password', 'host', 'port')) . '/' . lmb_env_get('LIMB_HTTP_OFFSET_PATH'); $base_path_uri = new lmbUri(rtrim($base_path, '/')); $base_path_uri->normalizePath(); $level = 1; while ($uri->getPathElement($level) == $base_path_uri->getPathElement($level) && $level < $base_path_uri->countPath()) { $level++; } return $level; }