function testMakingADirectoryUrlAbsolute() { $url = new SimpleUrl('hello/'); $this->assertEqual($url->getPath(), 'hello/'); $this->assertEqual($url->getBasePath(), 'hello/'); $this->assertEqual($url->getPage(), ''); $absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html'); $this->assertEqual($absolute->getPath(), '/I/am/here/hello/'); }
/** * Test to see if the URL is within the directory * tree of the realm. * @param SimpleUrl $url URL to test. * @return boolean True if subpath. * @access public */ function isWithin($url) { if ($this->isIn($this->root, $url->getBasePath())) { return true; } if ($this->isIn($this->root, $url->getBasePath() . $url->getPage() . '/')) { return true; } return false; }
function testAbsolutePathPageSplitting() { $url = new SimpleUrl("http://host.com/here/there/somewhere.php"); $this->assertEqual($url->getPath(), "/here/there/somewhere.php"); $this->assertEqual($url->getPage(), "somewhere.php"); $this->assertEqual($url->getBasePath(), "/here/there/"); }