diff options
Diffstat (limited to 'tests/units')
21 files changed, 592 insertions, 200 deletions
diff --git a/tests/units/Action/TaskAssignColorOnDueDateTest.php b/tests/units/Action/TaskAssignColorOnDueDateTest.php index 4bb87c06..cf1373d5 100644 --- a/tests/units/Action/TaskAssignColorOnDueDateTest.php +++ b/tests/units/Action/TaskAssignColorOnDueDateTest.php @@ -34,4 +34,26 @@ class TaskAssignColorOnDueDateTest extends Base $this->assertEquals('red', $tasks[0]['color_id']); $this->assertEquals('yellow', $tasks[1]['color_id']); } + + public function testChangeColorOnlyWhenNecessary() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'date_due' => strtotime('-1 day'), 'color_id' => 'red'))); + + $tasks = $taskFinderModel->getAll(1); + $event = new TaskListEvent(array('tasks' => $tasks, 'project_id' => 1)); + + $action = new TaskAssignColorOnDueDate($this->container); + $action->setProjectId(1); + $action->setParam('color_id', 'red'); + + $this->assertFalse($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); + + $tasks = $taskFinderModel->getAll(1); + $this->assertEquals('red', $tasks[0]['color_id']); + } } diff --git a/tests/units/Action/TaskAssignCreatorTest.php b/tests/units/Action/TaskAssignCreatorTest.php new file mode 100644 index 00000000..70bf9da5 --- /dev/null +++ b/tests/units/Action/TaskAssignCreatorTest.php @@ -0,0 +1,89 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Action\TaskAssignCreator; +use Kanboard\Event\TaskEvent; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; + +class TaskAssignCreatorTest extends Base +{ + public function testChangeUser() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0))); + + $event = new TaskEvent(array( + 'task_id' => 1, + 'task' => array( + 'project_id' => 1, + 'column_id' => 2, + 'creator_id' => 1, + ) + )); + + $action = new TaskAssignCreator($this->container); + $action->setProjectId(1); + $action->setParam('column_id', 2); + + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); + + $task = $taskFinderModel->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(1, $task['owner_id']); + } + + public function testWithoutCreator() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0))); + + $event = new TaskEvent(array( + 'task_id' => 1, + 'task' => array( + 'project_id' => 1, + 'column_id' => 2, + ) + )); + + $action = new TaskAssignCreator($this->container); + $action->setProjectId(1); + $action->setParam('column_id', 2); + + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); + } + + public function testWithWrongColumn() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); + + $event = new TaskEvent(array( + 'task_id' => 1, + 'task' => array( + 'project_id' => 1, + 'column_id' => 3, + 'creator_id' => 1, + ) + )); + + $action = new TaskAssignCreator($this->container); + $action->setProjectId(1); + $action->setParam('column_id', 2); + + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); + } +} diff --git a/tests/units/Action/TaskAssignDueDateOnCreationTest.php b/tests/units/Action/TaskAssignDueDateOnCreationTest.php index 26c0584e..64625d2c 100644 --- a/tests/units/Action/TaskAssignDueDateOnCreationTest.php +++ b/tests/units/Action/TaskAssignDueDateOnCreationTest.php @@ -32,6 +32,6 @@ class TaskAssignDueDateOnCreationTest extends Base $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(date('Y-m-d', strtotime('+4days')), date('Y-m-d', $task['date_due'])); + $this->assertEquals(date('Y-m-d H:i', strtotime('+4days')), date('Y-m-d H:i', $task['date_due'])); } } diff --git a/tests/units/Action/TaskAssignSpecificUserTest.php b/tests/units/Action/TaskAssignSpecificUserTest.php index 0e63fc13..9b0b8f5d 100644 --- a/tests/units/Action/TaskAssignSpecificUserTest.php +++ b/tests/units/Action/TaskAssignSpecificUserTest.php @@ -2,7 +2,6 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Event\GenericEvent; use Kanboard\Event\TaskEvent; use Kanboard\Model\TaskCreationModel; use Kanboard\Model\TaskFinderModel; diff --git a/tests/units/Base.php b/tests/units/Base.php index 1c93e9b8..f7c99425 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -101,5 +101,6 @@ abstract class Base extends PHPUnit_Framework_TestCase public function tearDown() { $this->container['db']->closeConnection(); + unset ($this->container); } } diff --git a/tests/units/Export/TaskExportTest.php b/tests/units/Export/TaskExportTest.php index e8b347ac..ca0fb8de 100644 --- a/tests/units/Export/TaskExportTest.php +++ b/tests/units/Export/TaskExportTest.php @@ -37,12 +37,13 @@ class TaskExportTest extends Base 'swimlane_id' => 2, 'title' => 'Task 2', 'date_due' => time(), + 'tags' => array('tag 1', 'tag 2'), ))); $report = $taskExport->export(1, date('Y-m-d'), date('Y-m-d')); $this->assertCount(3, $report); - $this->assertCount(22, $report[0]); + $this->assertCount(24, $report[0]); $this->assertEquals('Task Id', $report[0][0]); $this->assertEquals(1, $report[1][0]); @@ -70,12 +71,14 @@ class TaskExportTest extends Base $this->assertEquals('Yellow', $report[2][8]); $this->assertEquals('', $report[1][9]); - $this->assertEquals(date('m/d/Y').' 00:00', $report[2][9]); + $this->assertEquals(date('m/d/Y H:i'), $report[2][9]); $this->assertEquals(3, $report[1][21]); $this->assertEquals(0, $report[2][21]); $this->assertEquals(2.5, $report[1][20]); $this->assertEquals(0, $report[2][20]); + + $this->assertEquals('tag 1, tag 2', $report[2][23]); } } diff --git a/tests/units/Filter/TaskReferenceFilterTest.php b/tests/units/Filter/TaskReferenceFilterTest.php new file mode 100644 index 00000000..49a86454 --- /dev/null +++ b/tests/units/Filter/TaskReferenceFilterTest.php @@ -0,0 +1,65 @@ +<?php + +use Kanboard\Filter\TaskReferenceFilter; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; + +require_once __DIR__.'/../Base.php'; + +class TaskReferenceFilterTest extends Base +{ + public function testWithoutMatch() + { + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $query = $taskFinder->getExtendedQuery(); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); + + $filter = new TaskReferenceFilter(); + $filter->withQuery($query); + $filter->withValue('aaa-bbb'); + $filter->apply(); + + $this->assertCount(0, $query->findAll()); + } + + public function testWithExactMatch() + { + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $query = $taskFinder->getExtendedQuery(); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'reference' => 'aaa-bbb'))); + + $filter = new TaskReferenceFilter(); + $filter->withQuery($query); + $filter->withValue('aaa-bbb'); + $filter->apply(); + + $this->assertCount(1, $query->findAll()); + } + + public function testWithWildCard() + { + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $query = $taskFinder->getExtendedQuery(); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'reference' => 'aaa-bbb'))); + + $filter = new TaskReferenceFilter(); + $filter->withQuery($query); + $filter->withValue('aaa-*'); + $filter->apply(); + + $this->assertCount(1, $query->findAll()); + } +} diff --git a/tests/units/Helper/ProjectRoleHelperTest.php b/tests/units/Helper/ProjectRoleHelperTest.php index eb9b320c..d2335dfa 100644 --- a/tests/units/Helper/ProjectRoleHelperTest.php +++ b/tests/units/Helper/ProjectRoleHelperTest.php @@ -106,6 +106,116 @@ class ProjectRoleHelperTest extends Base $this->assertFalse($projectRoleHelper->canCreateTaskInColumn(1, 2)); } + public function testCanRemoveTaskWithCustomProjectRoleAndRestriction() + { + $projectRoleHelper = new ProjectRoleHelper($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectRoleModel = new ProjectRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container); + + $this->container['sessionStorage']->user = array( + 'id' => 2, + 'role' => Role::APP_USER, + ); + + $this->assertEquals(2, $userModel->create(array('username' => 'user'))); + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1 , 'title' => 'test'))); + + $this->assertEquals(1, $projectRoleModel->create(1, 'Custom Role')); + $this->assertTrue($projectUserRole->addUser(1, 2, 'Custom Role')); + + $this->assertEquals(1, $projectRoleRestrictionModel->create(1, 1, ProjectRoleRestrictionModel::RULE_TASK_SUPPRESSION)); + + $task = $taskFinderModel->getById(1); + $this->assertFalse($projectRoleHelper->canRemoveTask($task)); + } + + public function testCanRemoveTaskWithCustomProjectRole() + { + $projectRoleHelper = new ProjectRoleHelper($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectRoleModel = new ProjectRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + + $this->container['sessionStorage']->user = array( + 'id' => 2, + 'role' => Role::APP_USER, + ); + + $this->assertEquals(2, $userModel->create(array('username' => 'user'))); + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1 , 'title' => 'test'))); + + $this->assertEquals(1, $projectRoleModel->create(1, 'Custom Role')); + $this->assertTrue($projectUserRole->addUser(1, 2, 'Custom Role')); + + $task = $taskFinderModel->getById(1); + $this->assertTrue($projectRoleHelper->canRemoveTask($task)); + } + + public function testCanChangeAssigneeWithCustomProjectRoleAndRestriction() + { + $projectRoleHelper = new ProjectRoleHelper($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectRoleModel = new ProjectRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container); + + $this->container['sessionStorage']->user = array( + 'id' => 2, + 'role' => Role::APP_USER, + ); + + $this->assertEquals(2, $userModel->create(array('username' => 'user'))); + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1 , 'title' => 'test'))); + + $this->assertEquals(1, $projectRoleModel->create(1, 'Custom Role')); + $this->assertTrue($projectUserRole->addUser(1, 2, 'Custom Role')); + + $this->assertEquals(1, $projectRoleRestrictionModel->create(1, 1, ProjectRoleRestrictionModel::RULE_TASK_CHANGE_ASSIGNEE)); + + $task = $taskFinderModel->getById(1); + $this->assertFalse($projectRoleHelper->canChangeAssignee($task)); + } + + public function testCanChangeAssigneeWithCustomProjectRole() + { + $projectRoleHelper = new ProjectRoleHelper($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectRoleModel = new ProjectRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + + $this->container['sessionStorage']->user = array( + 'id' => 2, + 'role' => Role::APP_USER, + ); + + $this->assertEquals(2, $userModel->create(array('username' => 'user'))); + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1 , 'title' => 'test'))); + + $this->assertEquals(1, $projectRoleModel->create(1, 'Custom Role')); + $this->assertTrue($projectUserRole->addUser(1, 2, 'Custom Role')); + + $task = $taskFinderModel->getById(1); + $this->assertTrue($projectRoleHelper->canChangeAssignee($task)); + } + public function testCanChangeTaskStatusInColumnWithProjectViewer() { $projectRoleHelper = new ProjectRoleHelper($this->container); diff --git a/tests/units/Model/ProjectModelTest.php b/tests/units/Model/ProjectModelTest.php index 1f65cad7..7958ef0b 100644 --- a/tests/units/Model/ProjectModelTest.php +++ b/tests/units/Model/ProjectModelTest.php @@ -2,7 +2,13 @@ require_once __DIR__.'/../Base.php'; +use Kanboard\Api\Procedure\ProjectPermissionProcedure; +use Kanboard\Core\Security\Role; use Kanboard\Core\Translator; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\ProjectPermissionModel; +use Kanboard\Model\SwimlaneModel; +use Kanboard\Model\TagModel; use Kanboard\Subscriber\ProjectModificationDateSubscriber; use Kanboard\Model\ProjectModel; use Kanboard\Model\UserModel; @@ -43,6 +49,21 @@ class ProjectModelTest extends Base $this->assertEmpty($project['end_date']); } + public function testCreationWithUserId() + { + $projectModel = new ProjectModel($this->container); + + $this->assertFalse($projectModel->create(array('name' => 'UnitTest'), 3)); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'), 1)); + $project = $projectModel->getById(1); + $this->assertEquals(1, $project['owner_id']); + + $this->assertEquals(2, $projectModel->create(array('name' => 'UnitTest'), 0)); + $project = $projectModel->getById(2); + $this->assertEquals(0, $project['owner_id']); + } + public function testProjectDate() { $projectModel = new ProjectModel($this->container); @@ -159,6 +180,26 @@ class ProjectModelTest extends Base $this->assertGreaterThan($now, $project['last_modified']); } + public function testUpdateOwnerId() + { + $projectModel = new ProjectModel($this->container); + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $this->assertFalse($projectModel->update(array('id'=> 1, 'name' => 'test', 'owner_id' => 2))); + + $this->assertTrue($projectModel->update(array('id'=> 1, 'name' => 'test', 'owner_id' => 1))); + + $project = $projectModel->getById(1); + $this->assertNotEmpty($project); + $this->assertEquals(1, $project['owner_id']); + + $this->assertTrue($projectModel->update(array('id'=> 1, 'name' => 'test', 'owner_id' => 0))); + + $project = $projectModel->getById(1); + $this->assertNotEmpty($project); + $this->assertEquals(0, $project['owner_id']); + } + public function testGetAllIds() { $projectModel = new ProjectModel($this->container); @@ -207,6 +248,68 @@ class ProjectModelTest extends Base $this->assertFalse($projectModel->remove(1234)); } + public function testRemoveTagsOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $tagModel = new TagModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertNotFalse($tagModel->create(1, 'TestTag')); + + $this->assertCount(1, $tagModel->getAllByProject(1)); + + $this->assertTrue($projectModel->remove(1)); + + $this->assertCount(0, $tagModel->getAllByProject(1)); + } + + public function testRemoveSwimlaneOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $swimlaneModel = new SwimlaneModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $swimlaneId = $swimlaneModel->create(1, 'TestSwimlane'); + $this->assertNotFalse($swimlaneId); + + $this->assertTrue($projectModel->remove(1)); + $this->assertNull($swimlaneModel->getById($swimlaneId)); + } + + public function testRemoveColumnOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $columnId = $columnModel->create(1, 'TestColumn'); + $this->assertNotFalse($columnId); + + $this->assertTrue($projectModel->remove(1)); + $this->assertNull($columnModel->getById($columnId)); + } + + public function testRemovePermissionOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + + $permissionModel = new ProjectPermissionModel($this->container); + $permissionProcedure = new ProjectPermissionProcedure($this->container); + + $userId = $userModel->create(array('username' => 'user1')); + $this->assertNotFalse($userId); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $permissionProcedure->addProjectUser(1, $userId, Role::PROJECT_MEMBER); + + $this->assertTrue($permissionModel->isUserAllowed(1, $userId)); + $this->assertTrue($projectModel->remove(1)); + $this->assertFalse($permissionModel->isUserAllowed(1, $userId)); + } + public function testEnable() { $projectModel = new ProjectModel($this->container); @@ -354,4 +457,17 @@ class ProjectModelTest extends Base $this->assertEquals('', $project['owner_username']); $this->assertEquals(0, $project['owner_id']); } + + public function testGetList() + { + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project B'), 1)); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project A', 'is_private' => 1), 1)); + + $this->assertEquals(array(0 => 'None', 1 => 'Project B'), $projectModel->getList()); + $this->assertEquals(array(1 => 'Project B'), $projectModel->getList(false)); + $this->assertEquals(array(2 => 'Project A', 1 => 'Project B'), $projectModel->getList(false, false)); + $this->assertEquals(array(0 => 'None', 2 => 'Project A', 1 => 'Project B'), $projectModel->getList(true, false)); + } } diff --git a/tests/units/Model/ProjectPermissionModelTest.php b/tests/units/Model/ProjectPermissionModelTest.php index 7f604374..4b5a7476 100644 --- a/tests/units/Model/ProjectPermissionModelTest.php +++ b/tests/units/Model/ProjectPermissionModelTest.php @@ -120,18 +120,6 @@ class ProjectPermissionModelTest extends Base $this->assertEquals('Project 3', $users[0]['project_name']); } - public function testEverybodyAllowed() - { - $projectModel = new ProjectModel($this->container); - $projectPermission = new ProjectPermissionModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); - $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2', 'is_everybody_allowed' => 1))); - - $this->assertFalse($projectPermission->isEverybodyAllowed(1)); - $this->assertTrue($projectPermission->isEverybodyAllowed(2)); - } - public function testIsUserAllowed() { $userModel = new UserModel($this->container); diff --git a/tests/units/Model/ProjectRoleRestrictionModelTest.php b/tests/units/Model/ProjectRoleRestrictionModelTest.php index af0f9bf9..6f77f8a2 100644 --- a/tests/units/Model/ProjectRoleRestrictionModelTest.php +++ b/tests/units/Model/ProjectRoleRestrictionModelTest.php @@ -90,7 +90,7 @@ class ProjectRoleRestrictionModelTest extends Base $projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container); $rules = $projectRoleRestrictionModel->getRules(); - $this->assertCount(3, $rules); + $this->assertCount(6, $rules); $this->assertArrayHasKey(ProjectRoleRestrictionModel::RULE_TASK_OPEN_CLOSE, $rules); } } diff --git a/tests/units/Model/ProjectUserRoleTest.php b/tests/units/Model/ProjectUserRoleTest.php index d59b15c9..e45080eb 100644 --- a/tests/units/Model/ProjectUserRoleTest.php +++ b/tests/units/Model/ProjectUserRoleTest.php @@ -101,26 +101,6 @@ class ProjectUserRoleTest extends Base $this->assertEquals('', $userRoleModel->getUserRole(1, 2)); } - public function testGetRoleWithPublicProject() - { - $projectModel = new ProjectModel($this->container); - $userRoleModel = new ProjectUserRoleModel($this->container); - $userModel = new UserModel($this->container); - - $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1'))); - $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2'))); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test'), 2, true)); - - $this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2)); - $this->assertEquals(null, $userRoleModel->getUserRole(1, 3)); - - $this->assertTrue($projectModel->update(array('id' => 1, 'is_everybody_allowed' => 1))); - - $this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2)); - $this->assertEquals(Role::PROJECT_MEMBER, $userRoleModel->getUserRole(1, 3)); - } - public function testGetAssignableUsersWithDisabledUsers() { $projectModel = new ProjectModel($this->container); @@ -247,59 +227,6 @@ class ProjectUserRoleTest extends Base $this->assertEquals('admin', $users[1]); } - public function testGetAssignableUsersWithEverybodyAllowed() - { - $projectModel = new ProjectModel($this->container); - $userModel = new UserModel($this->container); - $userRoleModel = new ProjectUserRoleModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test', 'is_everybody_allowed' => 1))); - - $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1'))); - $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2'))); - $this->assertEquals(4, $userModel->create(array('username' => 'user3', 'name' => 'User3'))); - $this->assertEquals(5, $userModel->create(array('username' => 'user4', 'name' => 'User4'))); - - $users = $userRoleModel->getAssignableUsers(1); - $this->assertCount(5, $users); - - $this->assertEquals('admin', $users[1]); - $this->assertEquals('User1', $users[2]); - $this->assertEquals('User2', $users[3]); - $this->assertEquals('User3', $users[4]); - $this->assertEquals('User4', $users[5]); - } - - public function testGetAssignableUsersWithDisabledUsersAndEverybodyAllowed() - { - $projectModel = new ProjectModel($this->container); - $projectPermission = new ProjectPermissionModel($this->container); - $userModel = new UserModel($this->container); - $userRoleModel = new ProjectUserRoleModel($this->container); - - $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1'))); - $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2'))); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_everybody_allowed' => 1))); - - $this->assertTrue($projectPermission->isEverybodyAllowed(1)); - - $users = $userRoleModel->getAssignableUsers(1); - $this->assertCount(3, $users); - - $this->assertEquals('admin', $users[1]); - $this->assertEquals('User1', $users[2]); - $this->assertEquals('User2', $users[3]); - - $this->assertTrue($userModel->disable(2)); - - $users = $userRoleModel->getAssignableUsers(1); - $this->assertCount(2, $users); - - $this->assertEquals('admin', $users[1]); - $this->assertEquals('User2', $users[3]); - } - public function testGetProjectsByUser() { $userModel = new UserModel($this->container); diff --git a/tests/units/Model/SubtaskModelTest.php b/tests/units/Model/SubtaskModelTest.php index eed37cf3..8ad054d1 100644 --- a/tests/units/Model/SubtaskModelTest.php +++ b/tests/units/Model/SubtaskModelTest.php @@ -172,4 +172,33 @@ class SubtaskModelTest extends Base $this->assertEquals(1, $subtaskModel->getProjectId(1)); $this->assertEquals(0, $subtaskModel->getProjectId(2)); } + + public function testGetAllByTaskIds() + { + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1))); + + $this->assertCount(0, $subtaskModel->getAllByTaskIds(array())); + $this->assertCount(1, $subtaskModel->getAllByTaskIds(array(1))); + } + + public function testGetAllByTaskIdsAndAssignee() + { + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1, 'user_id' => 1))); + + $this->assertCount(0, $subtaskModel->getAllByTaskIdsAndAssignee(array(), 1)); + $this->assertCount(0, $subtaskModel->getAllByTaskIdsAndAssignee(array(1), 2)); + $this->assertCount(1, $subtaskModel->getAllByTaskIdsAndAssignee(array(1), 1)); + } } diff --git a/tests/units/Model/TaskCreationModelTest.php b/tests/units/Model/TaskCreationModelTest.php index ce9996d9..7723bece 100644 --- a/tests/units/Model/TaskCreationModelTest.php +++ b/tests/units/Model/TaskCreationModelTest.php @@ -248,7 +248,7 @@ class TaskCreationModelTest extends Base public function testDateDue() { - $date = '2014-11-23'; + $date = '2014-11-23 14:30'; $timestamp = strtotime('+2days'); $projectModel = new ProjectModel($this->container); $taskCreationModel = new TaskCreationModel($this->container); @@ -262,12 +262,12 @@ class TaskCreationModelTest extends Base $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); $this->assertEquals(1, $task['id']); - $this->assertEquals($date, date('Y-m-d', $task['date_due'])); + $this->assertEquals($date, date('Y-m-d H:i', $task['date_due'])); $task = $taskFinderModel->getById(2); $this->assertNotEmpty($task); $this->assertEquals(2, $task['id']); - $this->assertEquals(date('Y-m-d 00:00', $timestamp), date('Y-m-d 00:00', $task['date_due'])); + $this->assertEquals(date('Y-m-d H:i', $timestamp), date('Y-m-d H:i', $task['date_due'])); $task = $taskFinderModel->getById(3); $this->assertEquals(3, $task['id']); @@ -398,6 +398,6 @@ class TaskCreationModelTest extends Base $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); - $this->assertEquals('2050-01-10 00:00', date('Y-m-d H:i', $task['date_due'])); + $this->assertEquals('2050-01-10 12:30', date('Y-m-d H:i', $task['date_due'])); } } diff --git a/tests/units/Model/TaskDuplicationModelTest.php b/tests/units/Model/TaskDuplicationModelTest.php index 1fff110c..e4121ff9 100644 --- a/tests/units/Model/TaskDuplicationModelTest.php +++ b/tests/units/Model/TaskDuplicationModelTest.php @@ -93,7 +93,7 @@ class TaskDuplicationModelTest extends Base $this->assertEquals(1, $task['swimlane_id']); $this->assertEquals(3, $task['column_id']); $this->assertEquals(2, $task['position']); - $this->assertEquals('test', $task['title']); + $this->assertEquals('[DUPLICATE] test', $task['title']); $this->assertEquals(0, $task['time_spent']); } diff --git a/tests/units/Model/TaskModificationModelTest.php b/tests/units/Model/TaskModificationModelTest.php index f70561b3..a716cf3d 100644 --- a/tests/units/Model/TaskModificationModelTest.php +++ b/tests/units/Model/TaskModificationModelTest.php @@ -195,15 +195,15 @@ class TaskModificationModelTest extends Base $task = $taskFinderModel->getById(1); $this->assertEquals(0, $task['date_due']); - $this->assertTrue($taskModificationModel->update(array('id' => 1, 'date_due' => '2014-11-24'))); + $this->assertTrue($taskModificationModel->update(array('id' => 1, 'date_due' => '2014-11-24 14:30'))); $task = $taskFinderModel->getById(1); - $this->assertEquals('2014-11-24', date('Y-m-d', $task['date_due'])); + $this->assertEquals('2014-11-24 14:30', date('Y-m-d H:i', $task['date_due'])); $this->assertTrue($taskModificationModel->update(array('id' => 1, 'date_due' => time()))); $task = $taskFinderModel->getById(1); - $this->assertEquals(date('Y-m-d'), date('Y-m-d', $task['date_due'])); + $this->assertEquals(date('Y-m-d H:i'), date('Y-m-d H:i', $task['date_due'])); } public function testChangeStartedDate() diff --git a/tests/units/Model/TaskRecurrenceModelTest.php b/tests/units/Model/TaskRecurrenceModelTest.php index 85d77bc2..56f6cf84 100644 --- a/tests/units/Model/TaskRecurrenceModelTest.php +++ b/tests/units/Model/TaskRecurrenceModelTest.php @@ -106,7 +106,7 @@ class TaskRecurrenceModelTest extends Base $this->assertNotEmpty($task); $this->assertEquals(TaskModel::RECURRING_STATUS_PROCESSED, $task['recurrence_status']); $this->assertEquals(2, $task['recurrence_child']); - $this->assertEquals(1436486400, $task['date_due'], '', 2); + $this->assertEquals(1436561776, $task['date_due'], '', 2); $task = $taskFinderModel->getById(2); $this->assertNotEmpty($task); @@ -116,7 +116,7 @@ class TaskRecurrenceModelTest extends Base $this->assertEquals(TaskModel::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']); $this->assertEquals(1, $task['recurrence_parent']); $this->assertEquals(2, $task['recurrence_factor']); - $this->assertEquals($dateParser->removeTimeFromTimestamp(strtotime('+2 days')), $task['date_due'], '', 2); + $this->assertEquals(strtotime('+2 days'), $task['date_due'], '', 2); $tags = $taskTagModel->getList(2); $this->assertCount(2, $tags); diff --git a/tests/units/Model/UserNotificationTest.php b/tests/units/Model/UserNotificationTest.php index 6ee5c875..e568d204 100644 --- a/tests/units/Model/UserNotificationTest.php +++ b/tests/units/Model/UserNotificationTest.php @@ -179,55 +179,21 @@ class UserNotificationTest extends Base $this->assertEquals('user3@here', $users[2]['email']); } - public function testGetUsersWithNotificationsWhenEverybodyAllowed() - { - $u = new UserModel($this->container); - $p = new ProjectModel($this->container); - $n = new UserNotificationModel($this->container); - $pp = new ProjectPermissionModel($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1))); - $this->assertTrue($pp->isEverybodyAllowed(1)); - - // Email + Notifications enabled - $this->assertEquals(2, $u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1))); - - // No email + Notifications enabled - $this->assertEquals(3, $u->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1))); - - // Email + Notifications enabled - $this->assertEquals(4, $u->create(array('username' => 'user3', 'email' => 'user3@here', 'notifications_enabled' => 1))); - - // User disabled - $this->assertEquals(5, $u->create(array('username' => 'user4', 'email' => 'user3@here', 'notifications_enabled' => 1, 'is_active' => 0))); - - // No email + notifications disabled - $this->assertEquals(6, $u->create(array('username' => 'user5'))); - - $users = $n->getUsersWithNotificationEnabled(1); - - $this->assertNotEmpty($users); - $this->assertCount(3, $users); - $this->assertEquals('user1@here', $users[0]['email']); - $this->assertEquals('', $users[1]['email']); - $this->assertEquals('user3@here', $users[2]['email']); - } - public function testSendNotifications() { - $u = new UserModel($this->container); - $n = new UserNotificationModel($this->container); - $p = new ProjectModel($this->container); - $tc = new TaskCreationModel($this->container); - $tf = new TaskFinderModel($this->container); - $pp = new ProjectPermissionModel($this->container); + $userModel = new UserModel($this->container); + $userNotificationModel = new UserNotificationModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1))); - $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost'))); - $this->assertTrue($pp->isEverybodyAllowed(1)); + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1))); + $this->assertTrue($userModel->update(array('id' => 1, 'email' => 'test@localhost'))); + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MANAGER)); - $n->saveSettings(1, array( + $userNotificationModel->saveSettings(1, array( 'notifications_enabled' => 1, 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE, 'notification_types' => array('web' => 1, 'email' => 1), @@ -259,6 +225,6 @@ class UserNotificationTest extends Base ->with($this->equalTo('web')) ->will($this->returnValue($notifier)); - $n->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $userNotificationModel->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $taskFinderModel->getDetails(1))); } } diff --git a/tests/units/Pagination/DashboardPaginationTest.php b/tests/units/Pagination/DashboardPaginationTest.php new file mode 100644 index 00000000..6b0a40fb --- /dev/null +++ b/tests/units/Pagination/DashboardPaginationTest.php @@ -0,0 +1,121 @@ +<?php + +use Kanboard\Core\Security\Role; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\UserModel; +use Kanboard\Pagination\DashboardPagination; + +require_once __DIR__.'/../Base.php'; + +class DashboardPaginationTest extends Base +{ + public function testDashboardPagination() + { + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 2))); + $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); + + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask A', 'user_id' => 1))); + $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask B', 'user_id' => 1))); + $this->assertEquals(3, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask C'))); + + $dashboard = $dashboardPagination->getOverview(1); + $this->assertCount(1, $dashboard); + $this->assertEquals(1, $dashboard[0]['project_id']); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask B', $tasks[0]['subtasks'][0]['title']); + } + + public function testWhenUserIsNotAssignedToTask() + { + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER)); + $this->assertTrue($projectUserRoleModel->addUser(2, 2, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 2, 'priority' => 3))); + $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2))); + $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 2, 'owner_id' => 2))); + + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask A', 'user_id' => 2))); + $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask B', 'user_id' => 1))); + $this->assertEquals(3, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask C'))); + + $dashboard = $dashboardPagination->getOverview(1); + $this->assertCount(1, $dashboard); + $this->assertEquals(1, $dashboard[0]['project_id']); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask B', $tasks[0]['subtasks'][0]['title']); + + $dashboard = $dashboardPagination->getOverview(2); + $this->assertCount(2, $dashboard); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals('Project #2', $dashboard[1]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(0, $tasks[0]['subtasks']); + + $tasks = $dashboard[1]['paginator']->getCollection(); + $this->assertCount(2, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask A', $tasks[0]['subtasks'][0]['title']); + } + + public function testWhenColumnIsHidden() + { + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $columnModel = new ColumnModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); + + $this->assertCount(1, $dashboardPagination->getOverview(1)); + + $this->assertTrue($columnModel->update(1, 'test', 0, '', 1)); + $this->assertCount(0, $dashboardPagination->getOverview(1)); + } +} diff --git a/tests/units/Pagination/SubtaskPaginationTest.php b/tests/units/Pagination/SubtaskPaginationTest.php deleted file mode 100644 index 1e16c985..00000000 --- a/tests/units/Pagination/SubtaskPaginationTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -use Kanboard\Model\ColumnModel; -use Kanboard\Model\ProjectModel; -use Kanboard\Model\SubtaskModel; -use Kanboard\Model\TaskCreationModel; -use Kanboard\Model\TaskModel; -use Kanboard\Pagination\SubtaskPagination; - -require_once __DIR__.'/../Base.php'; - -class SubtaskPaginationTest extends Base -{ - public function testDashboardPagination() - { - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - $subtaskModel = new SubtaskModel($this->container); - $subtaskPagination = new SubtaskPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); - $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); - $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(3, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(4, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1'))); - $this->assertEquals(5, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1'))); - - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection()); - $this->assertCount(0, $subtaskPagination->getDashboardPaginator(2, 'subtasks', 5)->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(TaskModel::TABLE.'.id')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('project_name')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('task_name')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(SubtaskModel::TABLE.'.title')->getCollection()); - } - - public function testWhenColumnIsHidden() - { - $columnModel = new ColumnModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - $subtaskModel = new SubtaskModel($this->container); - $subtaskPagination = new SubtaskPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertTrue($columnModel->update(1, 'test', 0, '', 1)); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); - $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - - $this->assertCount(0, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection()); - } -} diff --git a/tests/units/Validator/TaskValidatorTest.php b/tests/units/Validator/TaskValidatorTest.php index 5c1b9a52..12c5a497 100644 --- a/tests/units/Validator/TaskValidatorTest.php +++ b/tests/units/Validator/TaskValidatorTest.php @@ -68,10 +68,19 @@ class TaskValidatorTest extends Base $this->assertFalse($result[0]); } - public function testDateField() + public function testStartAndDueDateFields() { $taskValidator = new TaskValidator($this->container); + $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 9:50')); + $this->assertTrue($result[0]); + + $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 10:50')); + $this->assertTrue($result[0]); + + $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 11:50')); + $this->assertFalse($result[0]); + // date_due // ISO dates $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01')); |