summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-08-15 17:23:41 -0700
committerFrédéric Guillot <fred@kanboard.net>2014-08-15 17:23:41 -0700
commit9eeded33f68872515954a2fc177fcb47a9273ae9 (patch)
treef3ef9507e087ca6bf3ce624232da240a8689b051 /tests/units
parentc539bdc8ab746c5afd48cf87de057dc38d50adac (diff)
Add email notifications
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/AclTest.php8
-rw-r--r--tests/units/ActionTaskAssignColorCategoryTest.php10
-rw-r--r--tests/units/ActionTaskAssignColorUserTest.php8
-rw-r--r--tests/units/ActionTaskAssignCurrentUserTest.php12
-rw-r--r--tests/units/ActionTaskAssignSpecificUserTest.php10
-rw-r--r--tests/units/ActionTaskCloseTest.php10
-rw-r--r--tests/units/ActionTaskDuplicateAnotherProjectTest.php10
-rw-r--r--tests/units/ActionTest.php46
-rw-r--r--tests/units/Base.php7
-rw-r--r--tests/units/BoardTest.php4
-rw-r--r--tests/units/CommentTest.php22
-rw-r--r--tests/units/ProjectTest.php18
-rw-r--r--tests/units/TaskTest.php44
13 files changed, 106 insertions, 103 deletions
diff --git a/tests/units/AclTest.php b/tests/units/AclTest.php
index a2c1c111..7dff0a69 100644
--- a/tests/units/AclTest.php
+++ b/tests/units/AclTest.php
@@ -12,7 +12,7 @@ class AclTest extends Base
'controller1' => array('action1', 'action3'),
);
- $acl = new Acl($this->db, $this->event);
+ $acl = new Acl($this->registry);
$this->assertTrue($acl->isAllowedAction($acl_rules, 'controller1', 'action1'));
$this->assertTrue($acl->isAllowedAction($acl_rules, 'controller1', 'action3'));
$this->assertFalse($acl->isAllowedAction($acl_rules, 'controller1', 'action2'));
@@ -22,7 +22,7 @@ class AclTest extends Base
public function testIsAdmin()
{
- $acl = new Acl($this->db, $this->event);
+ $acl = new Acl($this->registry);
$_SESSION = array();
$this->assertFalse($acl->isAdminUser());
@@ -45,7 +45,7 @@ class AclTest extends Base
public function testIsUser()
{
- $acl = new Acl($this->db, $this->event);
+ $acl = new Acl($this->registry);
$_SESSION = array();
$this->assertFalse($acl->isRegularUser());
@@ -68,7 +68,7 @@ class AclTest extends Base
public function testIsPageAllowed()
{
- $acl = new Acl($this->db, $this->event);
+ $acl = new Acl($this->registry);
// Public access
$_SESSION = array();
diff --git a/tests/units/ActionTaskAssignColorCategoryTest.php b/tests/units/ActionTaskAssignColorCategoryTest.php
index 18b4311e..84334dc5 100644
--- a/tests/units/ActionTaskAssignColorCategoryTest.php
+++ b/tests/units/ActionTaskAssignColorCategoryTest.php
@@ -10,7 +10,7 @@ class ActionTaskAssignColorCategory extends Base
{
public function testBadProject()
{
- $action = new Action\TaskAssignColorCategory(3, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignColorCategory(3, new Task($this->registry));
$event = array(
'project_id' => 2,
@@ -24,14 +24,14 @@ class ActionTaskAssignColorCategory extends Base
public function testExecute()
{
- $action = new Action\TaskAssignColorCategory(1, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignColorCategory(1, new Task($this->registry));
$action->setParam('category_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
- $c = new Category($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
+ $c = new Category($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $c->create(array('name' => 'c1')));
diff --git a/tests/units/ActionTaskAssignColorUserTest.php b/tests/units/ActionTaskAssignColorUserTest.php
index 04e3172f..ee71e87c 100644
--- a/tests/units/ActionTaskAssignColorUserTest.php
+++ b/tests/units/ActionTaskAssignColorUserTest.php
@@ -9,7 +9,7 @@ class ActionTaskAssignColorUser extends Base
{
public function testBadProject()
{
- $action = new Action\TaskAssignColorUser(3, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignColorUser(3, new Task($this->registry));
$event = array(
'project_id' => 2,
@@ -23,13 +23,13 @@ class ActionTaskAssignColorUser extends Base
public function testExecute()
{
- $action = new Action\TaskAssignColorUser(1, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignColorUser(1, new Task($this->registry));
$action->setParam('user_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
diff --git a/tests/units/ActionTaskAssignCurrentUserTest.php b/tests/units/ActionTaskAssignCurrentUserTest.php
index 0780b603..f67c1e28 100644
--- a/tests/units/ActionTaskAssignCurrentUserTest.php
+++ b/tests/units/ActionTaskAssignCurrentUserTest.php
@@ -10,7 +10,7 @@ class ActionTaskAssignCurrentUser extends Base
{
public function testBadProject()
{
- $action = new Action\TaskAssignCurrentUser(3, new Task($this->db, $this->event), new Acl($this->db, $this->event));
+ $action = new Action\TaskAssignCurrentUser(3, new Task($this->registry), new Acl($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -25,7 +25,7 @@ class ActionTaskAssignCurrentUser extends Base
public function testBadColumn()
{
- $action = new Action\TaskAssignCurrentUser(3, new Task($this->db, $this->event), new Acl($this->db, $this->event));
+ $action = new Action\TaskAssignCurrentUser(3, new Task($this->registry), new Acl($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -39,16 +39,16 @@ class ActionTaskAssignCurrentUser extends Base
public function testExecute()
{
- $action = new Action\TaskAssignCurrentUser(1, new Task($this->db, $this->event), new Acl($this->db, $this->event));
+ $action = new Action\TaskAssignCurrentUser(1, new Task($this->registry), new Acl($this->registry));
$action->setParam('column_id', 2);
$_SESSION = array(
'user' => array('id' => 5)
);
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
- $a = new Acl($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
+ $a = new Acl($this->registry);
$this->assertEquals(5, $a->getUserId());
$this->assertEquals(1, $p->create(array('name' => 'test')));
diff --git a/tests/units/ActionTaskAssignSpecificUserTest.php b/tests/units/ActionTaskAssignSpecificUserTest.php
index 3a919978..6fd454d5 100644
--- a/tests/units/ActionTaskAssignSpecificUserTest.php
+++ b/tests/units/ActionTaskAssignSpecificUserTest.php
@@ -9,7 +9,7 @@ class ActionTaskAssignSpecificUser extends Base
{
public function testBadProject()
{
- $action = new Action\TaskAssignSpecificUser(3, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignSpecificUser(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -24,7 +24,7 @@ class ActionTaskAssignSpecificUser extends Base
public function testBadColumn()
{
- $action = new Action\TaskAssignSpecificUser(3, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignSpecificUser(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -38,13 +38,13 @@ class ActionTaskAssignSpecificUser extends Base
public function testExecute()
{
- $action = new Action\TaskAssignSpecificUser(1, new Task($this->db, $this->event));
+ $action = new Action\TaskAssignSpecificUser(1, new Task($this->registry));
$action->setParam('column_id', 2);
$action->setParam('user_id', 1);
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
diff --git a/tests/units/ActionTaskCloseTest.php b/tests/units/ActionTaskCloseTest.php
index 0c864f42..a3a1eecc 100644
--- a/tests/units/ActionTaskCloseTest.php
+++ b/tests/units/ActionTaskCloseTest.php
@@ -9,7 +9,7 @@ class ActionTaskCloseTest extends Base
{
public function testBadProject()
{
- $action = new Action\TaskClose(3, new Task($this->db, $this->event));
+ $action = new Action\TaskClose(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -24,7 +24,7 @@ class ActionTaskCloseTest extends Base
public function testBadColumn()
{
- $action = new Action\TaskClose(3, new Task($this->db, $this->event));
+ $action = new Action\TaskClose(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -38,12 +38,12 @@ class ActionTaskCloseTest extends Base
public function testExecute()
{
- $action = new Action\TaskClose(1, new Task($this->db, $this->event));
+ $action = new Action\TaskClose(1, new Task($this->registry));
$action->setParam('column_id', 2);
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
diff --git a/tests/units/ActionTaskDuplicateAnotherProjectTest.php b/tests/units/ActionTaskDuplicateAnotherProjectTest.php
index 0b2e4bd5..4d995b64 100644
--- a/tests/units/ActionTaskDuplicateAnotherProjectTest.php
+++ b/tests/units/ActionTaskDuplicateAnotherProjectTest.php
@@ -9,7 +9,7 @@ class ActionTaskDuplicateAnotherProject extends Base
{
public function testBadProject()
{
- $action = new Action\TaskDuplicateAnotherProject(3, new Task($this->db, $this->event));
+ $action = new Action\TaskDuplicateAnotherProject(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -24,7 +24,7 @@ class ActionTaskDuplicateAnotherProject extends Base
public function testBadColumn()
{
- $action = new Action\TaskDuplicateAnotherProject(3, new Task($this->db, $this->event));
+ $action = new Action\TaskDuplicateAnotherProject(3, new Task($this->registry));
$action->setParam('column_id', 5);
$event = array(
@@ -38,11 +38,11 @@ class ActionTaskDuplicateAnotherProject extends Base
public function testExecute()
{
- $action = new Action\TaskDuplicateAnotherProject(1, new Task($this->db, $this->event));
+ $action = new Action\TaskDuplicateAnotherProject(1, new Task($this->registry));
// We create a task in the first column
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
diff --git a/tests/units/ActionTest.php b/tests/units/ActionTest.php
index 2eb12784..8108767d 100644
--- a/tests/units/ActionTest.php
+++ b/tests/units/ActionTest.php
@@ -12,9 +12,9 @@ class ActionTest extends Base
{
public function testFetchActions()
{
- $action = new Action($this->db, $this->event);
- $board = new Board($this->db, $this->event);
- $project = new Project($this->db, $this->event);
+ $action = new Action($this->registry);
+ $board = new Board($this->registry);
+ $project = new Project($this->registry);
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
@@ -48,10 +48,10 @@ class ActionTest extends Base
public function testEventMoveColumn()
{
- $task = new Task($this->db, $this->event);
- $board = new Board($this->db, $this->event);
- $project = new Project($this->db, $this->event);
- $action = new Action($this->db, $this->event);
+ $task = new Task($this->registry);
+ $board = new Board($this->registry);
+ $project = new Project($this->registry);
+ $action = new Action($this->registry);
// We create a project
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
@@ -86,8 +86,8 @@ class ActionTest extends Base
// We move our task
$task->move(1, 4, 1);
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_UPDATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_UPDATE));
// Our task should be closed
$t1 = $task->getById(1);
@@ -97,10 +97,10 @@ class ActionTest extends Base
public function testEventMovePosition()
{
- $task = new Task($this->db, $this->event);
- $board = new Board($this->db, $this->event);
- $project = new Project($this->db, $this->event);
- $action = new Action($this->db, $this->event);
+ $task = new Task($this->registry);
+ $board = new Board($this->registry);
+ $project = new Project($this->registry);
+ $action = new Action($this->registry);
// We create a project
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
@@ -138,7 +138,7 @@ class ActionTest extends Base
// We bind events
$action->attachEvents();
- $this->assertTrue($this->event->hasListener(Task::EVENT_MOVE_POSITION, 'Action\TaskAssignColorCategory'));
+ $this->assertTrue($this->registry->event->hasListener(Task::EVENT_MOVE_POSITION, 'Action\TaskAssignColorCategory'));
// Our task should have the color red and position=0
$t1 = $task->getById(1);
@@ -155,7 +155,7 @@ class ActionTest extends Base
$task->move(1, 1, 1); // task #1 to position 1
$task->move(2, 1, 0); // task #2 to position 0
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
// Both tasks should be green
$t1 = $task->getById(1);
@@ -171,10 +171,10 @@ class ActionTest extends Base
public function testExecuteMultipleActions()
{
- $task = new Task($this->db, $this->event);
- $board = new Board($this->db, $this->event);
- $project = new Project($this->db, $this->event);
- $action = new Action($this->db, $this->event);
+ $task = new Task($this->registry);
+ $board = new Board($this->registry);
+ $project = new Project($this->registry);
+ $action = new Action($this->registry);
// We create 2 projects
$this->assertEquals(1, $project->create(array('name' => 'unit_test1')));
@@ -213,8 +213,8 @@ class ActionTest extends Base
$action->attachEvents();
// Events should be attached
- $this->assertTrue($this->event->hasListener(Task::EVENT_CLOSE, 'Action\TaskDuplicateAnotherProject'));
- $this->assertTrue($this->event->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
+ $this->assertTrue($this->registry->event->hasListener(Task::EVENT_CLOSE, 'Action\TaskDuplicateAnotherProject'));
+ $this->assertTrue($this->registry->event->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
// Our task should be open, linked to the first project and in the first column
$t1 = $task->getById(1);
@@ -225,8 +225,8 @@ class ActionTest extends Base
// We move our task
$task->move(1, 4, 1);
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CLOSE));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CLOSE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// Our task should be closed
$t1 = $task->getById(1);
diff --git a/tests/units/Base.php b/tests/units/Base.php
index 1f8109ed..313e6f43 100644
--- a/tests/units/Base.php
+++ b/tests/units/Base.php
@@ -9,6 +9,8 @@ require_once __DIR__.'/../../app/Core/Security.php';
require_once __DIR__.'/../../vendor/PicoDb/Database.php';
require_once __DIR__.'/../../app/Schema/Sqlite.php';
+require_once __DIR__.'/../../app/Core/Registry.php';
+require_once __DIR__.'/../../app/Core/Tool.php';
require_once __DIR__.'/../../app/Core/Listener.php';
require_once __DIR__.'/../../app/Core/Event.php';
require_once __DIR__.'/../../app/Core/Translator.php';
@@ -36,8 +38,9 @@ abstract class Base extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->db = $this->getDbConnection();
- $this->event = new \Core\Event;
+ $this->registry = new \Core\Registry;
+ $this->registry->db = $this->getDbConnection();
+ $this->registry->event = new \Core\Event;
}
public function getDbConnection()
diff --git a/tests/units/BoardTest.php b/tests/units/BoardTest.php
index d5686b3f..23ea8808 100644
--- a/tests/units/BoardTest.php
+++ b/tests/units/BoardTest.php
@@ -9,8 +9,8 @@ class BoardTest extends Base
{
public function testMoveColumns()
{
- $p = new Project($this->db, $this->event);
- $b = new Board($this->db, $this->event);
+ $p = new Project($this->registry);
+ $b = new Board($this->registry);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
diff --git a/tests/units/CommentTest.php b/tests/units/CommentTest.php
index 46f05abc..fa790555 100644
--- a/tests/units/CommentTest.php
+++ b/tests/units/CommentTest.php
@@ -10,9 +10,9 @@ class CommentTest extends Base
{
public function testCreate()
{
- $c = new Comment($this->db, $this->event);
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $c = new Comment($this->registry);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -30,9 +30,9 @@ class CommentTest extends Base
public function testGetAll()
{
- $c = new Comment($this->db, $this->event);
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $c = new Comment($this->registry);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -51,9 +51,9 @@ class CommentTest extends Base
public function testUpdate()
{
- $c = new Comment($this->db, $this->event);
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $c = new Comment($this->registry);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -67,7 +67,7 @@ class CommentTest extends Base
public function testValidateCreation()
{
- $c = new Comment($this->db, $this->event);
+ $c = new Comment($this->registry);
$result = $c->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => 'bla'));
$this->assertTrue($result[0]);
@@ -96,7 +96,7 @@ class CommentTest extends Base
public function testValidateModification()
{
- $c = new Comment($this->db, $this->event);
+ $c = new Comment($this->registry);
$result = $c->validateModification(array('id' => 1, 'comment' => 'bla'));
$this->assertTrue($result[0]);
diff --git a/tests/units/ProjectTest.php b/tests/units/ProjectTest.php
index 5ca8177c..cb7aee36 100644
--- a/tests/units/ProjectTest.php
+++ b/tests/units/ProjectTest.php
@@ -12,7 +12,7 @@ class ProjectTest extends Base
{
public function testCreation()
{
- $p = new Project($this->db, $this->event);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertNotEmpty($p->getById(1));
@@ -21,10 +21,10 @@ class ProjectTest extends Base
public function testAllowEverybody()
{
// We create a regular user
- $user = new User($this->db, $this->event);
+ $user = new User($this->registry);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
- $p = new Project($this->db, $this->event);
+ $p = new Project($this->registry);
$this->assertEmpty($p->getAllowedUsers(1)); // Nobody is specified for the given project
$this->assertTrue($p->isUserAllowed(1, 1)); // Everybody should be allowed
$this->assertTrue($p->isUserAllowed(1, 2)); // Everybody should be allowed
@@ -32,8 +32,8 @@ class ProjectTest extends Base
public function testAllowUser()
{
- $p = new Project($this->db, $this->event);
- $user = new User($this->db, $this->event);
+ $p = new Project($this->registry);
+ $user = new User($this->registry);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
// We create a project
@@ -58,9 +58,9 @@ class ProjectTest extends Base
public function testRevokeUser()
{
- $p = new Project($this->db, $this->event);
+ $p = new Project($this->registry);
- $user = new User($this->db, $this->event);
+ $user = new User($this->registry);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
// We create a project
@@ -113,9 +113,9 @@ class ProjectTest extends Base
public function testUsersList()
{
- $p = new Project($this->db, $this->event);
+ $p = new Project($this->registry);
- $user = new User($this->db, $this->event);
+ $user = new User($this->registry);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
// We create project
diff --git a/tests/units/TaskTest.php b/tests/units/TaskTest.php
index b8b3cf46..1ea03fca 100644
--- a/tests/units/TaskTest.php
+++ b/tests/units/TaskTest.php
@@ -10,9 +10,9 @@ class TaskTest extends Base
{
public function testExport()
{
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
- $c = new Category($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
+ $c = new Category($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Export Project')));
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
@@ -45,8 +45,8 @@ class TaskTest extends Base
public function testFilter()
{
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test a', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'description' => 'biloute')));
@@ -114,7 +114,7 @@ class TaskTest extends Base
public function testDateFormat()
{
- $t = new Task($this->db, $this->event);
+ $t = new Task($this->registry);
$this->assertEquals('2014-03-05', date('Y-m-d', $t->getValidDate('2014-03-05', 'Y-m-d')));
$this->assertEquals('2014-03-05', date('Y-m-d', $t->getValidDate('2014_03_05', 'Y_m_d')));
@@ -133,8 +133,8 @@ class TaskTest extends Base
public function testDuplicateTask()
{
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
// We create a task and a project
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -146,7 +146,7 @@ class TaskTest extends Base
// We duplicate our task
$this->assertEquals(2, $t->duplicate(1));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CREATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $t->getById(2);
@@ -160,8 +160,8 @@ class TaskTest extends Base
public function testDuplicateToAnotherProject()
{
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -172,7 +172,7 @@ class TaskTest extends Base
// We duplicate our task to the 2nd project
$this->assertEquals(2, $t->duplicateToAnotherProject(1, 2));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CREATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $t->getById(2);
@@ -185,39 +185,39 @@ class TaskTest extends Base
public function testEvents()
{
- $t = new Task($this->db, $this->event);
- $p = new Project($this->db, $this->event);
+ $t = new Task($this->registry);
+ $p = new Project($this->registry);
// We create a project
$this->assertEquals(1, $p->create(array('name' => 'test')));
// We create task
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CREATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
// We update a task
$this->assertTrue($t->update(array('title' => 'test2', 'id' => 1)));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_UPDATE));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CREATE_UPDATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_UPDATE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE_UPDATE));
// We close our task
$this->assertTrue($t->close(1));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_CLOSE));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CLOSE));
// We open our task
$this->assertTrue($t->open(1));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_OPEN));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_OPEN));
// We change the column of our task
$this->assertTrue($t->move(1, 2, 1));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// We change the position of our task
$this->assertTrue($t->move(1, 2, 2));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
// We change the column and the position of our task
$this->assertTrue($t->move(1, 1, 3));
- $this->assertTrue($this->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
+ $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
}
}