summaryrefslogtreecommitdiff
path: root/tests/units/Core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Core')
-rw-r--r--tests/units/Core/HelperTest.php17
-rw-r--r--tests/units/Core/Http/RouterTest.php22
-rw-r--r--tests/units/Core/TemplateTest.php6
3 files changed, 33 insertions, 12 deletions
diff --git a/tests/units/Core/HelperTest.php b/tests/units/Core/HelperTest.php
new file mode 100644
index 00000000..b766dd96
--- /dev/null
+++ b/tests/units/Core/HelperTest.php
@@ -0,0 +1,17 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Core\Helper;
+
+class HelperTest extends Base
+{
+ public function testRegister()
+ {
+ $helper = new Helper($this->container);
+ $helper->register('foobar', '\Stdclass');
+
+ $this->assertInstanceOf('Stdclass', $helper->foobar);
+ $this->assertInstanceOf('Stdclass', $helper->getHelper('foobar'));
+ }
+}
diff --git a/tests/units/Core/Http/RouterTest.php b/tests/units/Core/Http/RouterTest.php
index 0b200ab5..75a3ba4f 100644
--- a/tests/units/Core/Http/RouterTest.php
+++ b/tests/units/Core/Http/RouterTest.php
@@ -40,21 +40,25 @@ namespace {
$this->assertEquals('userImport', $dispatcher->sanitize('userImport', 'default'));
}
- public function testGetPath()
+ public function testGetPathWithFolder()
{
- $dispatcher = new Router($this->container);
-
- $this->container['helper'] = new Helper($this->container);
+ $router = new Router($this->container);
$this->container['request'] = new Request($this->container, array('PHP_SELF' => '/index.php', 'REQUEST_URI' => '/a/b/c', 'REQUEST_METHOD' => 'GET'));
- $this->assertEquals('a/b/c', $dispatcher->getPath());
+ $this->assertEquals('a/b/c', $router->getPath());
+ }
- $this->container['helper'] = new Helper($this->container);
+ public function testGetPathWithQueryString()
+ {
+ $router = new Router($this->container);
$this->container['request'] = new Request($this->container, array('PHP_SELF' => '/index.php', 'REQUEST_URI' => '/a/b/something?test=a', 'QUERY_STRING' => 'test=a', 'REQUEST_METHOD' => 'GET'));
- $this->assertEquals('a/b/something', $dispatcher->getPath());
+ $this->assertEquals('a/b/something', $router->getPath());
+ }
- $this->container['helper'] = new Helper($this->container);
+ public function testGetPathWithSubFolderAndQueryString()
+ {
+ $router = new Router($this->container);
$this->container['request'] = new Request($this->container, array('PHP_SELF' => '/a/index.php', 'REQUEST_URI' => '/a/b/something?test=a', 'QUERY_STRING' => 'test=a', 'REQUEST_METHOD' => 'GET'));
- $this->assertEquals('b/something', $dispatcher->getPath());
+ $this->assertEquals('b/something', $router->getPath());
}
public function testDispatcherWithControllerNotFound()
diff --git a/tests/units/Core/TemplateTest.php b/tests/units/Core/TemplateTest.php
index 6e5ae00d..bd476c51 100644
--- a/tests/units/Core/TemplateTest.php
+++ b/tests/units/Core/TemplateTest.php
@@ -8,7 +8,7 @@ class TemplateTest extends Base
{
public function testGetTemplateFile()
{
- $t = new Template($this->container);
+ $t = new Template($this->container['helper']);
$this->assertStringEndsWith(
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'a'.DIRECTORY_SEPARATOR.'b.php',
$t->getTemplateFile('a'.DIRECTORY_SEPARATOR.'b')
@@ -17,7 +17,7 @@ class TemplateTest extends Base
public function testGetPluginTemplateFile()
{
- $t = new Template($this->container);
+ $t = new Template($this->container['helper']);
$this->assertStringEndsWith(
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'Myplugin'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'a'.DIRECTORY_SEPARATOR.'b.php',
$t->getTemplateFile('myplugin:a'.DIRECTORY_SEPARATOR.'b')
@@ -26,7 +26,7 @@ class TemplateTest extends Base
public function testGetOverridedTemplateFile()
{
- $t = new Template($this->container);
+ $t = new Template($this->container['helper']);
$t->setTemplateOverride('a'.DIRECTORY_SEPARATOR.'b', 'myplugin:c');
$this->assertStringEndsWith(