summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/Core/PluginLoaderTest.php23
-rw-r--r--tests/units/Core/TemplateTest.php28
-rw-r--r--tests/units/Model/AclTest.php12
-rw-r--r--tests/units/Model/ProjectTest.php2
4 files changed, 64 insertions, 1 deletions
diff --git a/tests/units/Core/PluginLoaderTest.php b/tests/units/Core/PluginLoaderTest.php
new file mode 100644
index 00000000..62327f01
--- /dev/null
+++ b/tests/units/Core/PluginLoaderTest.php
@@ -0,0 +1,23 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Core\PluginLoader;
+
+class PluginLoaderTest extends Base
+{
+ public function testGetSchemaVersion()
+ {
+ $p = new PluginLoader($this->container);
+ $this->assertEquals(0, $p->getSchemaVersion('not_found'));
+
+ $this->assertTrue($p->setSchemaVersion('plugin1', 1));
+ $this->assertEquals(1, $p->getSchemaVersion('plugin1'));
+
+ $this->assertTrue($p->setSchemaVersion('plugin2', 33));
+ $this->assertEquals(33, $p->getSchemaVersion('plugin2'));
+
+ $this->assertTrue($p->setSchemaVersion('plugin1', 2));
+ $this->assertEquals(2, $p->getSchemaVersion('plugin1'));
+ }
+}
diff --git a/tests/units/Core/TemplateTest.php b/tests/units/Core/TemplateTest.php
new file mode 100644
index 00000000..9833397b
--- /dev/null
+++ b/tests/units/Core/TemplateTest.php
@@ -0,0 +1,28 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Core\Template;
+
+class TemplateTest extends Base
+{
+ public function testGetTemplateFile()
+ {
+ $t = new Template($this->container);
+ $this->assertStringEndsWith('app/Core/../Template/a/b.php', $t->getTemplateFile('a/b'));
+ }
+
+ public function testGetPluginTemplateFile()
+ {
+ $t = new Template($this->container);
+ $this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/a/b.php', $t->getTemplateFile('myplugin:a/b'));
+ }
+
+ public function testGetOverridedTemplateFile()
+ {
+ $t = new Template($this->container);
+ $t->setTemplateOverride('a/b', 'myplugin:c');
+ $this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/c.php', $t->getTemplateFile('a/b'));
+ $this->assertStringEndsWith('app/Core/../Template/d.php', $t->getTemplateFile('d'));
+ }
+}
diff --git a/tests/units/Model/AclTest.php b/tests/units/Model/AclTest.php
index fef03990..3cb28a77 100644
--- a/tests/units/Model/AclTest.php
+++ b/tests/units/Model/AclTest.php
@@ -290,4 +290,16 @@ class AclTest extends Base
$this->assertFalse($acl->isAllowed('task', 'remove', 1));
$this->assertTrue($acl->isAllowed('app', 'index', 1));
}
+
+ public function testExtend()
+ {
+ $acl = new Acl($this->container);
+
+ $this->assertFalse($acl->isProjectManagerAction('plop', 'show'));
+
+ $acl->extend('project_manager_acl', array('plop' => '*'));
+
+ $this->assertTrue($acl->isProjectManagerAction('plop', 'show'));
+ $this->assertTrue($acl->isProjectManagerAction('swimlane', 'index'));
+ }
}
diff --git a/tests/units/Model/ProjectTest.php b/tests/units/Model/ProjectTest.php
index 97357796..9d7b6c0d 100644
--- a/tests/units/Model/ProjectTest.php
+++ b/tests/units/Model/ProjectTest.php
@@ -26,7 +26,7 @@ class ProjectTest extends Base
$this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language);
}
- Translator::load('en_US');
+ Translator::unload();
}
public function testCreation()