public function getIndexForUri($uri)
{
preg_match('~\\/?(.*?\\.php)~', $uri, $matches);
if (!empty($matches[1])) {
$uri = '/' . $matches[1];
}
if (file_exists($this->root . $uri) && !is_dir($this->root . $uri)) {
return $this->root . $uri;
}
$uri = '/' . trim($uri, '/');
$indexFile = isset($this->map[$uri]) ? $this->map[$uri] : '/index.php';
return $this->root . $indexFile;
}
/** * @test * it should set index with uri to index map when setting index for uri */ public function it_should_set_index_with_uri_to_index_map_when_setting_index_for_uri() { $uri = '/foo'; $this->uriToIndexMapper->setRoot($this->root->url())->shouldBeCalled(); $this->uriToIndexMapper->getIndexForUri($uri)->willReturn('/some-index.php'); $sut = $this->make_instance(); $sut->setRootFolder($this->root->url()); $sut->setIndexFor($uri); $this->assertEquals($this->root->url() . '/some-index.php', $sut->getIndex()); }