Return application url if defined for the helper getCurrentBaseUrl()
This commit is contained in:
parent
22f44ef788
commit
b028b3586c
|
|
@ -515,6 +515,12 @@ class Helper
|
|||
*/
|
||||
public function getCurrentBaseUrl()
|
||||
{
|
||||
$application_url = $this->config->get('application_url');
|
||||
|
||||
if (! empty($application_url)) {
|
||||
return $application_url;
|
||||
}
|
||||
|
||||
$self = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
|
||||
|
||||
$url = Request::isHTTPS() ? 'https://' : 'http://';
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Core\Helper;
|
||||
use Model\Config;
|
||||
|
||||
class HelperTest extends Base
|
||||
{
|
||||
|
|
@ -30,4 +31,20 @@ class HelperTest extends Base
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetCurrentBaseUrl()
|
||||
{
|
||||
$h = new Helper($this->container);
|
||||
|
||||
$_SERVER['PHP_SELF'] = '/';
|
||||
$_SERVER['SERVER_NAME'] = 'localhost';
|
||||
$_SERVER['SERVER_PORT'] = 1234;
|
||||
|
||||
$this->assertEquals('http://localhost:1234/', $h->getCurrentBaseUrl());
|
||||
|
||||
$c = new Config($this->container);
|
||||
$c->save(array('application_url' => 'https://mykanboard/'));
|
||||
$this->assertEquals('https://mykanboard/', $c->get('application_url'));
|
||||
$this->assertEquals('https://mykanboard/', $h->getCurrentBaseUrl());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue