summaryrefslogtreecommitdiff
path: root/tests/units/UrlHelperTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/UrlHelperTest.php')
-rw-r--r--tests/units/UrlHelperTest.php30
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/units/UrlHelperTest.php b/tests/units/UrlHelperTest.php
index d70842aa..ebfe9c99 100644
--- a/tests/units/UrlHelperTest.php
+++ b/tests/units/UrlHelperTest.php
@@ -34,30 +34,52 @@ class UrlHelperTest extends Base
);
}
+ public function testDir()
+ {
+ $h = new Url($this->container);
+ $this->assertEquals('', $h->dir());
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['PHP_SELF'] = '/plop/index.php';
+ $h = new Url($this->container);
+ $this->assertEquals('/plop/', $h->dir());
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['PHP_SELF'] = '';
+ $h = new Url($this->container);
+ $this->assertEquals('/', $h->dir());
+ }
+
public function testServer()
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->server());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->server());
+ $this->assertEquals('http://kb:1234/', $h->server());
}
public function testBase()
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->base());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->base());
+ $h = new Url($this->container);
+ $this->assertEquals('http://kb:1234/', $h->base());
$c = new Config($this->container);
$c->save(array('application_url' => 'https://mykanboard/'));
+ $h = new Url($this->container);
$this->assertEquals('https://mykanboard/', $c->get('application_url'));
$this->assertEquals('https://mykanboard/', $h->base());
}