Move task creation to a seperate class
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\Category;
|
||||
@@ -30,7 +31,7 @@ class ActionTaskAssignColorCategory extends Base
|
||||
$action->setParam('color_id', 'blue');
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
@@ -38,7 +39,7 @@ class ActionTaskAssignColorCategory extends Base
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $c->create(array('name' => 'c1')));
|
||||
$this->assertEquals(2, $c->create(array('name' => 'c2')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
|
||||
|
||||
// We create an event but we don't do anything
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
|
||||
@@ -29,11 +30,11 @@ class ActionTaskAssignColorUser extends Base
|
||||
$action->setParam('color_id', 'blue');
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$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')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
|
||||
|
||||
// We change the assignee
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\Acl;
|
||||
@@ -47,14 +48,14 @@ class ActionTaskAssignCurrentUser extends Base
|
||||
);
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$a = new Acl($this->container);
|
||||
|
||||
$this->assertEquals(5, $a->getUserId());
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We create an event to move the task to the 2nd column
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
|
||||
@@ -44,11 +45,11 @@ class ActionTaskAssignSpecificUser extends Base
|
||||
$action->setParam('user_id', 1);
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We create an event to move the task to the 2nd column
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\GithubWebhook;
|
||||
@@ -82,11 +83,11 @@ class ActionTaskCloseTest extends Base
|
||||
$action->setParam('column_id', 2);
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We create an event to move the task to the 2nd column
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
|
||||
@@ -42,12 +43,12 @@ class ActionTaskDuplicateAnotherProject extends Base
|
||||
$action = new Action\TaskDuplicateAnotherProject($this->container, 1, Task::EVENT_MOVE_COLUMN);
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We create an event to move the task to the 2nd column
|
||||
$event = array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
|
||||
@@ -42,12 +43,12 @@ class ActionTaskMoveAnotherProject extends Base
|
||||
$action = new Action\TaskMoveAnotherProject($this->container, 1, Task::EVENT_MOVE_COLUMN);
|
||||
|
||||
// We create a task in the first column
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We create an event to move the task to the 2nd column
|
||||
$event = array(
|
||||
|
||||
@@ -6,6 +6,7 @@ use Model\Action;
|
||||
use Model\Project;
|
||||
use Model\Board;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Category;
|
||||
|
||||
@@ -49,7 +50,8 @@ class ActionTest extends Base
|
||||
|
||||
public function testEventMoveColumn()
|
||||
{
|
||||
$task = new Task($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$board = new Board($this->container);
|
||||
$project = new Project($this->container);
|
||||
@@ -59,7 +61,7 @@ class ActionTest extends Base
|
||||
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
|
||||
|
||||
// We create a task
|
||||
$this->assertEquals(1, $task->create(array(
|
||||
$this->assertEquals(1, $tc->create(array(
|
||||
'title' => 'unit_test',
|
||||
'project_id' => 1,
|
||||
'owner_id' => 1,
|
||||
@@ -86,7 +88,7 @@ class ActionTest extends Base
|
||||
$this->assertEquals(1, $t1['column_id']);
|
||||
|
||||
// We move our task
|
||||
$task->movePosition(1, 1, 4, 1);
|
||||
$t->movePosition(1, 1, 4, 1);
|
||||
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
|
||||
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_UPDATE));
|
||||
@@ -99,7 +101,8 @@ class ActionTest extends Base
|
||||
|
||||
public function testExecuteMultipleActions()
|
||||
{
|
||||
$task = new Task($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$board = new Board($this->container);
|
||||
$project = new Project($this->container);
|
||||
@@ -110,7 +113,7 @@ class ActionTest extends Base
|
||||
$this->assertEquals(2, $project->create(array('name' => 'unit_test2')));
|
||||
|
||||
// We create a task
|
||||
$this->assertEquals(1, $task->create(array(
|
||||
$this->assertEquals(1, $tc->create(array(
|
||||
'title' => 'unit_test',
|
||||
'project_id' => 1,
|
||||
'owner_id' => 1,
|
||||
@@ -152,7 +155,7 @@ class ActionTest extends Base
|
||||
$this->assertEquals(1, $t1['project_id']);
|
||||
|
||||
// We move our task
|
||||
$task->movePosition(1, 1, 4, 1);
|
||||
$t->movePosition(1, 1, 4, 1);
|
||||
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE));
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\Category;
|
||||
@@ -12,7 +13,7 @@ class CategoryTest extends Base
|
||||
{
|
||||
public function testCreation()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
@@ -20,7 +21,7 @@ class CategoryTest extends Base
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertTrue(is_array($task));
|
||||
@@ -35,7 +36,7 @@ class CategoryTest extends Base
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
@@ -43,7 +44,7 @@ class CategoryTest extends Base
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertTrue(is_array($task));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\Project;
|
||||
use Model\Comment;
|
||||
|
||||
@@ -11,11 +12,11 @@ class CommentTest extends Base
|
||||
public function testCreate()
|
||||
{
|
||||
$c = new Comment($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1)));
|
||||
|
||||
$comment = $c->getById(1);
|
||||
@@ -31,11 +32,11 @@ class CommentTest extends Base
|
||||
public function testGetAll()
|
||||
{
|
||||
$c = new Comment($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c2', 'user_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c3', 'user_id' => 1)));
|
||||
@@ -54,11 +55,11 @@ class CommentTest extends Base
|
||||
public function testUpdate()
|
||||
{
|
||||
$c = new Comment($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
|
||||
$this->assertTrue($c->update(array('id' => 1, 'comment' => 'bla')));
|
||||
|
||||
@@ -70,11 +71,11 @@ class CommentTest extends Base
|
||||
public function validateRemove()
|
||||
{
|
||||
$c = new Comment($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$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)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
|
||||
$this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
|
||||
|
||||
$this->assertTrue($c->remove(1));
|
||||
|
||||
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskFinder;
|
||||
use Model\TaskCreation;
|
||||
use Model\ProjectActivity;
|
||||
use Model\Project;
|
||||
|
||||
@@ -12,13 +13,13 @@ class ProjectActivityTest extends Base
|
||||
public function testCreation()
|
||||
{
|
||||
$e = new ProjectActivity($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1)));
|
||||
|
||||
$this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
|
||||
$this->assertTrue($e->createEvent(1, 2, 1, Task::EVENT_UPDATE, array('task' => $tf->getById(2))));
|
||||
@@ -37,12 +38,12 @@ class ProjectActivityTest extends Base
|
||||
public function testFetchAllContent()
|
||||
{
|
||||
$e = new ProjectActivity($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
|
||||
$nb_events = 80;
|
||||
|
||||
@@ -63,12 +64,12 @@ class ProjectActivityTest extends Base
|
||||
public function testCleanup()
|
||||
{
|
||||
$e = new ProjectActivity($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
|
||||
$max = 15;
|
||||
$nb_events = 100;
|
||||
|
||||
@@ -5,6 +5,7 @@ require_once __DIR__.'/Base.php';
|
||||
use Model\Project;
|
||||
use Model\ProjectDailySummary;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
|
||||
class ProjectDailySummaryTest extends Base
|
||||
{
|
||||
@@ -12,27 +13,27 @@ class ProjectDailySummaryTest extends Base
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$pds = new ProjectDailySummary($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
|
||||
$this->assertEquals(0, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')));
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 1)));
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 4)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 4)));
|
||||
}
|
||||
|
||||
$pds->updateTotals(1, date('Y-m-d', strtotime('-2days')));
|
||||
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 3)));
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 25; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 2)));
|
||||
}
|
||||
|
||||
$pds->updateTotals(1, date('Y-m-d', strtotime('-1 day')));
|
||||
@@ -41,15 +42,15 @@ class ProjectDailySummaryTest extends Base
|
||||
$this->assertNotFalse($t->close(2));
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 3)));
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 2)));
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$this->assertNotFalse($t->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 4)));
|
||||
$this->assertNotFalse($tc->create(array('title' => 'Task #'.$i, 'project_id' => 1, 'column_id' => 4)));
|
||||
}
|
||||
|
||||
$pds->updateTotals(1, date('Y-m-d'));
|
||||
|
||||
@@ -6,6 +6,7 @@ use Model\Project;
|
||||
use Model\ProjectPermission;
|
||||
use Model\User;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\Acl;
|
||||
use Model\Board;
|
||||
|
||||
@@ -48,7 +49,7 @@ class ProjectTest extends Base
|
||||
public function testIsLastModified()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
|
||||
$now = time();
|
||||
$p->attachEvents();
|
||||
@@ -61,7 +62,7 @@ class ProjectTest extends Base
|
||||
|
||||
sleep(1);
|
||||
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||
$this->assertEquals('Event\ProjectModificationDateListener', $this->container['event']->getLastListenerExecuted());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\SubTask;
|
||||
use Model\Project;
|
||||
use Model\Category;
|
||||
@@ -12,7 +13,7 @@ class SubTaskTest extends Base
|
||||
{
|
||||
public function testDuplicate()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$s = new SubTask($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
@@ -20,8 +21,8 @@ class SubTaskTest extends Base
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||
|
||||
// We create 2 tasks
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 0)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 0)));
|
||||
|
||||
// We create many subtasks for the first task
|
||||
$this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5, 'time_spent' => 3, 'status' => 1, 'another_subtask' => 'on')));
|
||||
|
||||
330
tests/units/TaskCreationTest.php
Normal file
330
tests/units/TaskCreationTest.php
Normal file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\TaskStatus;
|
||||
use Model\Project;
|
||||
use Model\ProjectPermission;
|
||||
|
||||
class TaskCreationTest extends Base
|
||||
{
|
||||
public function testNoProjectId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(0, $tc->create(array('title' => 'test', 'project_id' => 0)));
|
||||
|
||||
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||
}
|
||||
|
||||
public function testNoTitle()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(0, $tc->create(array('project_id' => 1)));
|
||||
|
||||
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||
}
|
||||
|
||||
public function testMinimum()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
|
||||
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals('yellow', $task['color_id']);
|
||||
$this->assertEquals(1, $task['project_id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(0, $task['creator_id']);
|
||||
|
||||
$this->assertEquals('test', $task['title']);
|
||||
$this->assertEquals('', $task['description']);
|
||||
$this->assertEquals('', $task['reference']);
|
||||
|
||||
$this->assertEquals(time(), $task['date_creation']);
|
||||
$this->assertEquals(time(), $task['date_modification']);
|
||||
$this->assertEquals(0, $task['date_due']);
|
||||
$this->assertEquals(0, $task['date_completed']);
|
||||
$this->assertEquals(0, $task['date_started']);
|
||||
|
||||
$this->assertEquals(0, $task['time_estimated']);
|
||||
$this->assertEquals(0, $task['time_spent']);
|
||||
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(1, $task['is_active']);
|
||||
$this->assertEquals(0, $task['score']);
|
||||
}
|
||||
|
||||
public function testColorId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'color_id' => 'blue')));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals('blue', $task['color_id']);
|
||||
}
|
||||
|
||||
public function testOwnerId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 1)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1, $task['owner_id']);
|
||||
}
|
||||
|
||||
public function testCategoryId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'category_id' => 1)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1, $task['category_id']);
|
||||
}
|
||||
|
||||
public function testCreatorId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'creator_id' => 1)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1, $task['creator_id']);
|
||||
}
|
||||
|
||||
public function testColumnId()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
}
|
||||
|
||||
public function testPosition()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
|
||||
$this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2)));
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
}
|
||||
|
||||
public function testDescription()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'description' => 'test')));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals('test', $task['description']);
|
||||
}
|
||||
|
||||
public function testReference()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'reference' => 'test')));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals('test', $task['reference']);
|
||||
}
|
||||
|
||||
public function testDateDue()
|
||||
{
|
||||
$date = '2014-11-23';
|
||||
$timestamp = strtotime('+2days');
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_due' => $date)));
|
||||
$this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_due' => $timestamp)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals($date, date('Y-m-d', $task['date_due']));
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals($timestamp, $task['date_due']);
|
||||
}
|
||||
|
||||
public function testDateStarted()
|
||||
{
|
||||
$date = '2014-11-23';
|
||||
$timestamp = strtotime('+2days');
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $date)));
|
||||
$this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $timestamp)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals($date, date('Y-m-d', $task['date_started']));
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals($timestamp, $task['date_started']);
|
||||
}
|
||||
|
||||
public function testTime()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'time_estimated' => 1.5, 'time_spent' => 2.3)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1.5, $task['time_estimated']);
|
||||
$this->assertEquals(2.3, $task['time_spent']);
|
||||
}
|
||||
|
||||
public function testStripColumn()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'another_task' => '1')));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
}
|
||||
|
||||
public function testScore()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'score' => '3')));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertNotFalse($task);
|
||||
$this->assertEquals(3, $task['score']);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskExport;
|
||||
use Model\Project;
|
||||
use Model\Category;
|
||||
@@ -12,7 +13,7 @@ class TaskExportTest extends Base
|
||||
{
|
||||
public function testExport()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
$e = new TaskExport($this->container);
|
||||
@@ -36,7 +37,7 @@ class TaskExportTest extends Base
|
||||
'score' => rand(0, 21)
|
||||
);
|
||||
|
||||
$this->assertEquals($i, $t->create($task));
|
||||
$this->assertEquals($i, $tc->create($task));
|
||||
}
|
||||
|
||||
$rows = $e->export(1, strtotime('-1 day'), strtotime('+1 day'));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\ProjectPermission;
|
||||
@@ -13,15 +14,15 @@ class TaskFinderTest extends Base
|
||||
{
|
||||
public function testGetOverdueTasks()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(4, $t->create(array('title' => 'Task #3', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #3', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasks();
|
||||
$this->assertNotEmpty($tasks);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\TaskPermission;
|
||||
use Model\Project;
|
||||
@@ -13,7 +14,7 @@ class TaskPermissionTest extends Base
|
||||
{
|
||||
public function testPrepareCreation()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$tp = new TaskPermission($this->container);
|
||||
$p = new Project($this->container);
|
||||
@@ -22,10 +23,10 @@ class TaskPermissionTest extends Base
|
||||
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456')));
|
||||
$this->assertTrue($u->create(array('username' => 'toto2', 'password' => '123456')));
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'creator_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'creator_id' => 2)));
|
||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'creator_id' => 3)));
|
||||
$this->assertEquals(4, $t->create(array('title' => 'Task #4', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'creator_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'creator_id' => 2)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'creator_id' => 3)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1)));
|
||||
|
||||
// User #1 can remove everything
|
||||
$user = $u->getbyId(1);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\TaskStatus;
|
||||
use Model\Project;
|
||||
@@ -12,13 +13,13 @@ class TaskStatusTest extends Base
|
||||
{
|
||||
public function testStatus()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$ts = new TaskStatus($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
|
||||
|
||||
// The task must be open
|
||||
|
||||
@@ -32,8 +33,7 @@ class TaskStatusTest extends Base
|
||||
|
||||
// We close the task
|
||||
|
||||
$ts->close(1);
|
||||
|
||||
$this->assertTrue($ts->close(1));
|
||||
$this->assertTrue($ts->isClosed(1));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
@@ -46,8 +46,7 @@ class TaskStatusTest extends Base
|
||||
|
||||
// We open the task again
|
||||
|
||||
$ts->open(1);
|
||||
|
||||
$this->assertTrue($ts->open(1));
|
||||
$this->assertTrue($ts->isOpen(1));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\TaskStatus;
|
||||
use Model\Project;
|
||||
@@ -12,151 +13,15 @@ use Model\User;
|
||||
|
||||
class TaskTest extends Base
|
||||
{
|
||||
public function testPrepareCreation()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
|
||||
$input = array(
|
||||
'title' => 'youpi',
|
||||
'description' => '',
|
||||
'project_id' => '1',
|
||||
'owner_id' => '0',
|
||||
'category_id' => '0',
|
||||
'column_id' => '2',
|
||||
'color_id' => 'yellow',
|
||||
'score' => '',
|
||||
'date_due' => '',
|
||||
'creator_id' => '1',
|
||||
'another_task' => '1',
|
||||
);
|
||||
|
||||
$t->prepareCreation($input);
|
||||
|
||||
$this->assertInternalType('integer', $input['date_due']);
|
||||
$this->assertEquals(0, $input['date_due']);
|
||||
|
||||
$this->assertInternalType('integer', $input['score']);
|
||||
$this->assertEquals(0, $input['score']);
|
||||
|
||||
$this->assertArrayNotHasKey('another_task', $input);
|
||||
|
||||
$this->assertArrayHasKey('date_creation', $input);
|
||||
$this->assertEquals(time(), $input['date_creation']);
|
||||
|
||||
$this->assertArrayHasKey('date_modification', $input);
|
||||
$this->assertEquals(time(), $input['date_modification']);
|
||||
|
||||
$this->assertArrayHasKey('position', $input);
|
||||
$this->assertGreaterThan(0, $input['position']);
|
||||
|
||||
$input = array(
|
||||
'title' => 'youpi',
|
||||
'project_id' => '1',
|
||||
);
|
||||
|
||||
$t->prepareCreation($input);
|
||||
|
||||
$this->assertArrayNotHasKey('date_due', $input);
|
||||
$this->assertArrayNotHasKey('score', $input);
|
||||
|
||||
$this->assertArrayHasKey('date_creation', $input);
|
||||
$this->assertEquals(time(), $input['date_creation']);
|
||||
|
||||
$this->assertArrayHasKey('date_modification', $input);
|
||||
$this->assertEquals(time(), $input['date_modification']);
|
||||
|
||||
$this->assertArrayHasKey('position', $input);
|
||||
$this->assertGreaterThan(0, $input['position']);
|
||||
|
||||
$this->assertArrayHasKey('color_id', $input);
|
||||
$this->assertEquals('yellow', $input['color_id']);
|
||||
|
||||
$this->assertArrayHasKey('column_id', $input);
|
||||
$this->assertEquals(1, $input['column_id']);
|
||||
|
||||
$input = array(
|
||||
'title' => 'youpi',
|
||||
'project_id' => '1',
|
||||
'date_due' => '2014-09-15',
|
||||
);
|
||||
|
||||
$t->prepareCreation($input);
|
||||
|
||||
$this->assertArrayHasKey('date_due', $input);
|
||||
$this->assertInternalType('integer', $input['date_due']);
|
||||
$this->assertEquals('2014-09-15', date('Y-m-d', $input['date_due']));
|
||||
}
|
||||
|
||||
public function testPrepareModification()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
|
||||
$input = array(
|
||||
'id' => '1',
|
||||
'description' => 'Boo',
|
||||
);
|
||||
|
||||
$t->prepareModification($input);
|
||||
|
||||
$this->assertArrayNotHasKey('id', $input);
|
||||
$this->assertArrayHasKey('date_modification', $input);
|
||||
$this->assertEquals(time(), $input['date_modification']);
|
||||
}
|
||||
|
||||
public function testCreation()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals('yellow', $task['color_id']);
|
||||
$this->assertEquals(time(), $task['date_creation']);
|
||||
$this->assertEquals(time(), $task['date_modification']);
|
||||
$this->assertEquals(0, $task['date_due']);
|
||||
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(time(), $task['date_creation']);
|
||||
$this->assertEquals(time(), $task['date_modification']);
|
||||
$this->assertEquals(0, $task['date_due']);
|
||||
|
||||
$tasks = $tf->getAll(1, 1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertEquals(1, $tasks[0]['id']);
|
||||
$this->assertEquals(2, $tasks[1]['id']);
|
||||
|
||||
$tasks = $tf->getAll(1, 0);
|
||||
$this->assertEmpty($tasks);
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
|
||||
$this->assertTrue($t->remove(1));
|
||||
$this->assertFalse($t->remove(1234));
|
||||
@@ -165,19 +30,20 @@ class TaskTest extends Base
|
||||
public function testMoveTaskWithColumnThatNotChange()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $t->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(5, $t->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(6, $t->create(array('title' => 'Task #6', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(7, $t->create(array('title' => 'Task #7', 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertEquals(8, $t->create(array('title' => 'Task #8', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(6, $tc->create(array('title' => 'Task #6', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(7, $tc->create(array('title' => 'Task #7', 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertEquals(8, $tc->create(array('title' => 'Task #8', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// We move the task 3 to the column 3
|
||||
$this->assertTrue($t->movePosition(1, 3, 3, 2));
|
||||
@@ -227,6 +93,7 @@ class TaskTest extends Base
|
||||
public function testMoveTaskWithBadPreviousPosition()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
@@ -260,14 +127,15 @@ class TaskTest extends Base
|
||||
public function testMoveTaskTop()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $t->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// Move the last task to the top
|
||||
$this->assertTrue($t->movePosition(1, 4, 1, 1));
|
||||
@@ -297,14 +165,15 @@ class TaskTest extends Base
|
||||
public function testMoveTaskBottom()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $t->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// Move the last task to hte top
|
||||
$this->assertTrue($t->movePosition(1, 1, 1, 4));
|
||||
@@ -334,6 +203,7 @@ class TaskTest extends Base
|
||||
public function testMovePosition()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
@@ -352,7 +222,7 @@ class TaskTest extends Base
|
||||
'owner_id' => 0,
|
||||
);
|
||||
|
||||
$this->assertEquals($counter, $t->create($task));
|
||||
$this->assertEquals($counter, $tc->create($task));
|
||||
|
||||
$task = $tf->getById($counter);
|
||||
$this->assertNotFalse($task);
|
||||
@@ -489,6 +359,7 @@ class TaskTest extends Base
|
||||
public function testDuplicateToTheSameProject()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
@@ -502,7 +373,7 @@ class TaskTest extends Base
|
||||
$this->assertTrue($c->exists(1, 1));
|
||||
$this->assertTrue($c->exists(2, 1));
|
||||
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertNotEmpty($task);
|
||||
@@ -526,6 +397,7 @@ class TaskTest extends Base
|
||||
public function testDuplicateToAnotherProject()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$c = new Category($this->container);
|
||||
@@ -538,7 +410,7 @@ class TaskTest extends Base
|
||||
$this->assertTrue($c->exists(1, 1));
|
||||
|
||||
// We create a task
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
||||
$task = $tf->getById(1);
|
||||
|
||||
// We duplicate our task to the 2nd project
|
||||
@@ -559,6 +431,7 @@ class TaskTest extends Base
|
||||
public function testMoveToAnotherProject()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$pp = new ProjectPermission($this->container);
|
||||
@@ -573,8 +446,8 @@ class TaskTest extends Base
|
||||
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||
|
||||
// We create a task
|
||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333)));
|
||||
$this->assertEquals(2, $t->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
|
||||
|
||||
// We duplicate our task to the 2nd project
|
||||
$task = $tf->getById(1);
|
||||
@@ -606,6 +479,7 @@ class TaskTest extends Base
|
||||
public function testEvents()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$ts = new TaskStatus($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
@@ -613,7 +487,7 @@ class TaskTest extends Base
|
||||
$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->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||
|
||||
// We update a task
|
||||
@@ -634,7 +508,7 @@ class TaskTest extends Base
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
|
||||
|
||||
// We change the position of our task
|
||||
$this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 2)));
|
||||
$this->assertTrue($t->movePosition(1, 1, 2, 2));
|
||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\SubTask;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
use Model\TimeTracking;
|
||||
@@ -13,13 +14,14 @@ class TimeTrackingTest extends Base
|
||||
public function testCalculateTime()
|
||||
{
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$s = new SubTask($this->container);
|
||||
$ts = new TimeTracking($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
|
||||
$this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
|
||||
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\User;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Project;
|
||||
|
||||
@@ -119,13 +120,13 @@ class UserTest extends Base
|
||||
public function testRemove()
|
||||
{
|
||||
$u = new User($this->container);
|
||||
$t = new Task($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertEquals(1, $task['id']);
|
||||
|
||||
Reference in New Issue
Block a user