// common piece will be the path to the root controller.
$request_uri = $this->request()->data['_SERVER']['REQUEST_URI'];
$path_info = $this->request()->data['_SERVER']['PATH_INFO'];
- $common_uri = strstr($request_uri, $path_info, TRUE);
+ if ($path_info === NULL)
+ $common_uri = substr($request_uri, 0, -1);
+ else
+ $common_uri = strstr($request_uri, $path_info, TRUE);
// If just constructing an absolute path, return that now.
if (!$url)
$this->assertEquals($mock->MakeURL('/', TRUE), 'https://www.bluestatic.org:8080/hoplite/webapp/');
$this->assertEquals($mock->MakeURL('/path/3', TRUE), 'https://www.bluestatic.org:8080/hoplite/webapp/path/3');
}
+
+ public function testAbsolutifyRoot()
+ {
+ $globals = array(
+ '_SERVER' => array(
+ 'HTTP_HOST' => 'www.bluestatic.org',
+ 'REQUEST_URI' => '/hoplite/webapp/',
+ 'PATH_INFO' => NULL,
+ 'SERVER_PORT' => 80,
+ ),
+ );
+ $mock = new \hoplite\http\RootController($globals);
+
+ $this->assertEquals($mock->MakeURL('/'), '/hoplite/webapp/');
+ $this->assertEquals($mock->MakeURL('/', TRUE), 'http://www.bluestatic.org/hoplite/webapp/');
+
+ $globals['_SERVER']['HTTPS'] = 'on';
+ $globals['_SERVER']['SERVER_PORT'] = 443;
+ $mock = new \hoplite\http\RootController($globals);
+ $this->assertEquals($mock->MakeURL('/'), '/hoplite/webapp/');
+ $this->assertEquals($mock->MakeURL('/', TRUE), 'https://www.bluestatic.org/hoplite/webapp/');
+
+ $this->assertEquals($mock->MakeURL('/path/2'), '/hoplite/webapp/path/2');
+ $this->assertEquals($mock->MakeURL('/path/3', TRUE), 'https://www.bluestatic.org/hoplite/webapp/path/3');
+
+ $globals['_SERVER']['SERVER_PORT'] = 8080;
+ $mock = new \hoplite\http\RootController($globals);
+ $this->assertEquals($mock->MakeURL('/path/2'), '/hoplite/webapp/path/2');
+ $this->assertEquals($mock->MakeURL('/', TRUE), 'https://www.bluestatic.org:8080/hoplite/webapp/');
+ $this->assertEquals($mock->MakeURL('/path/3', TRUE), 'https://www.bluestatic.org:8080/hoplite/webapp/path/3');
+ }
}