summaryrefslogtreecommitdiff
path: root/tests/units/Helper
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-22 19:06:03 +0100
committerFrederic Guillot <fred@kanboard.net>2015-12-22 19:06:03 +0100
commit6f9af3659c9146a2ac1b08d70610bf96398ec073 (patch)
tree21cbbca979a30d133d421881d6aa6e6af8096199 /tests/units/Helper
parentc83f589b22cd548c6de10bfb0c18f767ba7dffd8 (diff)
Added the possiblity to define custom routes from plugins
Diffstat (limited to 'tests/units/Helper')
-rw-r--r--tests/units/Helper/UrlHelperTest.php77
1 files changed, 58 insertions, 19 deletions
diff --git a/tests/units/Helper/UrlHelperTest.php b/tests/units/Helper/UrlHelperTest.php
index cbacbc73..405e9462 100644
--- a/tests/units/Helper/UrlHelperTest.php
+++ b/tests/units/Helper/UrlHelperTest.php
@@ -4,10 +4,32 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Helper\Url;
use Kanboard\Model\Config;
+use Kanboard\Core\Http\Request;
class UrlHelperTest extends Base
{
- public function testLink()
+ public function testPluginLink()
+ {
+ $h = new Url($this->container);
+ $this->assertEquals(
+ '<a href="?controller=a&amp;action=b&amp;d=e&amp;plugin=something" class="f" title="g" target="_blank">label</a>',
+ $h->link('label', 'a', 'b', array('d' => 'e', 'plugin' => 'something'), false, 'f', 'g', true)
+ );
+ }
+
+ public function testPluginLinkWithRouteDefined()
+ {
+ $this->container['route']->enable();
+ $this->container['route']->addRoute('/myplugin/something/:d', 'a', 'b', 'something');
+
+ $h = new Url($this->container);
+ $this->assertEquals(
+ '<a href="myplugin/something/e" class="f" title="g" target="_blank">label</a>',
+ $h->link('label', 'a', 'b', array('d' => 'e', 'plugin' => 'something'), false, 'f', 'g', true)
+ );
+ }
+
+ public function testAppLink()
{
$h = new Url($this->container);
$this->assertEquals(
@@ -36,42 +58,59 @@ class UrlHelperTest extends Base
public function testDir()
{
- $h = new Url($this->container);
- $this->assertEquals('', $h->dir());
+ $this->container['request'] = new Request($this->container, array(
+ 'PHP_SELF' => '/kanboard/index.php',
+ 'REQUEST_METHOD' => 'GET'
+ )
+ );
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_SERVER['PHP_SELF'] = '/plop/index.php';
$h = new Url($this->container);
- $this->assertEquals('/plop/', $h->dir());
+ $this->assertEquals('/kanboard/', $h->dir());
+
+ $this->container['request'] = new Request($this->container, array(
+ 'PHP_SELF' => '/index.php',
+ 'REQUEST_METHOD' => 'GET'
+ )
+ );
- $_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->container['request'] = new Request($this->container, array(
+ 'PHP_SELF' => '/index.php',
+ 'REQUEST_METHOD' => 'GET',
+ 'SERVER_NAME' => 'localhost',
+ 'SERVER_PORT' => 80,
+ )
+ );
+ $h = new Url($this->container);
$this->assertEquals('http://localhost/', $h->server());
- $_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'kb';
- $_SERVER['SERVER_PORT'] = 1234;
+ $this->container['request'] = new Request($this->container, array(
+ 'PHP_SELF' => '/index.php',
+ 'REQUEST_METHOD' => 'GET',
+ 'SERVER_NAME' => 'kb',
+ 'SERVER_PORT' => 1234,
+ )
+ );
+ $h = new Url($this->container);
$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'] = 'kb';
- $_SERVER['SERVER_PORT'] = 1234;
+ $this->container['request'] = new Request($this->container, array(
+ 'PHP_SELF' => '/index.php',
+ 'REQUEST_METHOD' => 'GET',
+ 'SERVER_NAME' => 'kb',
+ 'SERVER_PORT' => 1234,
+ )
+ );
$h = new Url($this->container);
$this->assertEquals('http://kb:1234/', $h->base());