diff options
Diffstat (limited to 'tests')
114 files changed, 2252 insertions, 2253 deletions
diff --git a/tests/integration/ApiTest.php b/tests/integration/ApiTest.php index 5fed0368..f552bea9 100644 --- a/tests/integration/ApiTest.php +++ b/tests/integration/ApiTest.php @@ -51,9 +51,9 @@ class Api extends PHPUnit_Framework_TestCase if ($projects) { foreach ($projects as $project) { - $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']); - $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']); - $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']); + $this->assertEquals('http://127.0.0.1:8000/?controller=BoardViewController&action=show&project_id='.$project['id'], $project['url']['board']); + $this->assertEquals('http://127.0.0.1:8000/?controller=CalendarController&action=show&project_id='.$project['id'], $project['url']['calendar']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskListController&action=show&project_id='.$project['id'], $project['url']['list']); $this->assertTrue($this->client->removeProject($project['id'])); } } @@ -71,9 +71,9 @@ class Api extends PHPUnit_Framework_TestCase $project = $this->client->getProjectById(1); $this->assertNotEmpty($project); $this->assertEquals(1, $project['id']); - $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']); - $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']); - $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']); + $this->assertEquals('http://127.0.0.1:8000/?controller=BoardViewController&action=show&project_id='.$project['id'], $project['url']['board']); + $this->assertEquals('http://127.0.0.1:8000/?controller=CalendarController&action=show&project_id='.$project['id'], $project['url']['calendar']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskListController&action=show&project_id='.$project['id'], $project['url']['list']); } public function testGetProjectByName() @@ -81,9 +81,9 @@ class Api extends PHPUnit_Framework_TestCase $project = $this->client->getProjectByName('API test'); $this->assertNotEmpty($project); $this->assertEquals(1, $project['id']); - $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']); - $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']); - $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']); + $this->assertEquals('http://127.0.0.1:8000/?controller=BoardViewController&action=show&project_id='.$project['id'], $project['url']['board']); + $this->assertEquals('http://127.0.0.1:8000/?controller=CalendarController&action=show&project_id='.$project['id'], $project['url']['calendar']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskListController&action=show&project_id='.$project['id'], $project['url']['list']); $project = $this->client->getProjectByName(array('name' => 'API test')); $this->assertNotEmpty($project); @@ -100,9 +100,9 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNotEmpty($projects); foreach ($projects as $project) { - $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']); - $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']); - $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']); + $this->assertEquals('http://127.0.0.1:8000/?controller=BoardViewController&action=show&project_id='.$project['id'], $project['url']['board']); + $this->assertEquals('http://127.0.0.1:8000/?controller=CalendarController&action=show&project_id='.$project['id'], $project['url']['calendar']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskListController&action=show&project_id='.$project['id'], $project['url']['list']); } } @@ -235,7 +235,7 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNotFalse($task); $this->assertTrue(is_array($task)); $this->assertEquals('Task #1', $task['title']); - $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskViewController&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']); } public function testGetAllTasks() @@ -245,7 +245,7 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNotFalse($tasks); $this->assertTrue(is_array($tasks)); $this->assertEquals('Task #1', $tasks[0]['title']); - $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$tasks[0]['id'].'&project_id='.$tasks[0]['project_id'], $tasks[0]['url']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskViewController&action=show&task_id='.$tasks[0]['id'].'&project_id='.$tasks[0]['project_id'], $tasks[0]['url']); $tasks = $this->client->getAllTasks(2, 0); @@ -896,7 +896,7 @@ class Api extends PHPUnit_Framework_TestCase $this->assertNotEmpty($task); $this->assertEquals('Task with external ticket number', $task['title']); $this->assertEquals('TICKET-1234', $task['reference']); - $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']); + $this->assertEquals('http://127.0.0.1:8000/?controller=TaskViewController&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']); } public function testCreateOverdueTask() diff --git a/tests/units/Action/CommentCreationMoveTaskColumnTest.php b/tests/units/Action/CommentCreationMoveTaskColumnTest.php index 9615865d..5eaf515e 100644 --- a/tests/units/Action/CommentCreationMoveTaskColumnTest.php +++ b/tests/units/Action/CommentCreationMoveTaskColumnTest.php @@ -3,10 +3,10 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Comment; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\CommentModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\CommentCreationMoveTaskColumn; class CommentCreationMoveTaskColumnTest extends Base @@ -15,9 +15,9 @@ class CommentCreationMoveTaskColumnTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $commentModel = new Comment($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $commentModel = new CommentModel($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'))); @@ -28,7 +28,7 @@ class CommentCreationMoveTaskColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $comment = $commentModel->getById(1); $this->assertNotEmpty($comment); @@ -39,8 +39,8 @@ class CommentCreationMoveTaskColumnTest extends Base public function testWithUserNotLogged() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -51,6 +51,6 @@ class CommentCreationMoveTaskColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Action/CommentCreationTest.php b/tests/units/Action/CommentCreationTest.php index a2e52dc6..4a2fc386 100644 --- a/tests/units/Action/CommentCreationTest.php +++ b/tests/units/Action/CommentCreationTest.php @@ -3,11 +3,11 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Comment; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\User; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\CommentModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\UserModel; use Kanboard\Action\CommentCreation; use Kanboard\Core\Security\Role; @@ -15,11 +15,11 @@ class CommentCreationTest extends Base { public function testSuccess() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $commentModel = new Comment($this->container); - $taskCreationModel = new TaskCreation($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $commentModel = new CommentModel($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'))); @@ -44,10 +44,10 @@ class CommentCreationTest extends Base public function testWithUserNotAssignable() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $commentModel = new Comment($this->container); - $taskCreationModel = new TaskCreation($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $commentModel = new CommentModel($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'))); @@ -71,9 +71,9 @@ class CommentCreationTest extends Base public function testWithNoComment() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $userModel = new UserModel($this->container); + $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'))); diff --git a/tests/units/Action/TaskAssignCategoryColorTest.php b/tests/units/Action/TaskAssignCategoryColorTest.php index b386d9bf..09c08264 100644 --- a/tests/units/Action/TaskAssignCategoryColorTest.php +++ b/tests/units/Action/TaskAssignCategoryColorTest.php @@ -3,21 +3,21 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Category; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignCategoryColor; class TaskAssignCategoryColorTest extends Base { public function testChangeCategory() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -30,7 +30,7 @@ class TaskAssignCategoryColorTest extends Base $action->setParam('color_id', 'red'); $action->setParam('category_id', 1); - $this->assertTrue($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -39,9 +39,9 @@ class TaskAssignCategoryColorTest extends Base public function testWithWrongColor() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -54,6 +54,6 @@ class TaskAssignCategoryColorTest extends Base $action->setParam('color_id', 'red'); $action->setParam('category_id', 1); - $this->assertFalse($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); } } diff --git a/tests/units/Action/TaskAssignCategoryLabelTest.php b/tests/units/Action/TaskAssignCategoryLabelTest.php index ba988a72..1ddb1f7a 100644 --- a/tests/units/Action/TaskAssignCategoryLabelTest.php +++ b/tests/units/Action/TaskAssignCategoryLabelTest.php @@ -3,20 +3,20 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Category; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskAssignCategoryLabel; class TaskAssignCategoryLabelTest extends Base { public function testChangeCategory() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -39,9 +39,9 @@ class TaskAssignCategoryLabelTest extends Base public function testWithWrongLabel() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -60,9 +60,9 @@ class TaskAssignCategoryLabelTest extends Base public function testWithExistingCategory() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $categoryModel = new CategoryModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'c1', 'project_id' => 1))); diff --git a/tests/units/Action/TaskAssignCategoryLinkTest.php b/tests/units/Action/TaskAssignCategoryLinkTest.php index ba0e7152..712c3c02 100644 --- a/tests/units/Action/TaskAssignCategoryLinkTest.php +++ b/tests/units/Action/TaskAssignCategoryLinkTest.php @@ -2,11 +2,11 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\TaskLink; -use Kanboard\Model\Category; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskLinkModel; +use Kanboard\Model\CategoryModel; use Kanboard\Event\TaskLinkEvent; use Kanboard\Action\TaskAssignCategoryLink; @@ -14,10 +14,10 @@ class TaskAssignCategoryLinkTest extends Base { public function testAssignCategory() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); $action = new TaskAssignCategoryLink($this->container); $action->setProjectId(1); @@ -35,7 +35,7 @@ class TaskAssignCategoryLinkTest extends Base 'link_id' => 2, )); - $this->assertTrue($action->execute($event, TaskLink::EVENT_CREATE_UPDATE)); + $this->assertTrue($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE)); $task = $tf->getById(1); $this->assertEquals(1, $task['category_id']); @@ -43,10 +43,10 @@ class TaskAssignCategoryLinkTest extends Base public function testWhenLinkDontMatch() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); $action = new TaskAssignCategoryLink($this->container); $action->setProjectId(1); @@ -64,14 +64,14 @@ class TaskAssignCategoryLinkTest extends Base 'link_id' => 2, )); - $this->assertFalse($action->execute($event, TaskLink::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE)); } public function testThatExistingCategoryWillNotChange() { - $tc = new TaskCreation($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); $action = new TaskAssignCategoryLink($this->container); $action->setProjectId(1); @@ -90,6 +90,6 @@ class TaskAssignCategoryLinkTest extends Base 'link_id' => 2, )); - $this->assertFalse($action->execute($event, TaskLink::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE)); } } diff --git a/tests/units/Action/TaskAssignColorCategoryTest.php b/tests/units/Action/TaskAssignColorCategoryTest.php index 86c855d1..6502035f 100644 --- a/tests/units/Action/TaskAssignColorCategoryTest.php +++ b/tests/units/Action/TaskAssignColorCategoryTest.php @@ -3,21 +3,21 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Category; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignColorCategory; class TaskAssignColorCategoryTest extends Base { public function testChangeColor() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -30,7 +30,7 @@ class TaskAssignColorCategoryTest extends Base $action->setParam('color_id', 'red'); $action->setParam('category_id', 1); - $this->assertTrue($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -39,8 +39,8 @@ class TaskAssignColorCategoryTest extends Base public function testWithWrongCategory() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -52,6 +52,6 @@ class TaskAssignColorCategoryTest extends Base $action->setParam('color_id', 'red'); $action->setParam('category_id', 1); - $this->assertFalse($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); } } diff --git a/tests/units/Action/TaskAssignColorColumnTest.php b/tests/units/Action/TaskAssignColorColumnTest.php index 130422b5..d4ba8e01 100644 --- a/tests/units/Action/TaskAssignColorColumnTest.php +++ b/tests/units/Action/TaskAssignColorColumnTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignColorColumn; class TaskAssignColorColumnTest extends Base { public function testChangeColumn() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -27,7 +27,7 @@ class TaskAssignColorColumnTest extends Base $action->setParam('color_id', 'red'); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -36,8 +36,8 @@ class TaskAssignColorColumnTest extends Base public function testWithWrongCategory() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -49,6 +49,6 @@ class TaskAssignColorColumnTest extends Base $action->setParam('color_id', 'red'); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Action/TaskAssignColorLinkTest.php b/tests/units/Action/TaskAssignColorLinkTest.php index 6df029d3..07d0969b 100644 --- a/tests/units/Action/TaskAssignColorLinkTest.php +++ b/tests/units/Action/TaskAssignColorLinkTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\TaskLink; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskLinkModel; use Kanboard\Action\TaskAssignColorLink; class TaskAssignColorLinkTest extends Base { public function testChangeColor() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -27,7 +27,7 @@ class TaskAssignColorLinkTest extends Base $action->setParam('color_id', 'red'); $action->setParam('link_id', 1); - $this->assertTrue($action->execute($event, TaskLink::EVENT_CREATE_UPDATE)); + $this->assertTrue($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -36,8 +36,8 @@ class TaskAssignColorLinkTest extends Base public function testWithWrongLink() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -49,6 +49,6 @@ class TaskAssignColorLinkTest extends Base $action->setParam('color_id', 'red'); $action->setParam('link_id', 1); - $this->assertFalse($action->execute($event, TaskLink::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskLinkModel::EVENT_CREATE_UPDATE)); } } diff --git a/tests/units/Action/TaskAssignColorPriorityTest.php b/tests/units/Action/TaskAssignColorPriorityTest.php index be6d8727..2fce8e66 100644 --- a/tests/units/Action/TaskAssignColorPriorityTest.php +++ b/tests/units/Action/TaskAssignColorPriorityTest.php @@ -3,21 +3,21 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Category; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignColorPriority; class TaskAssignColorPriorityTest extends Base { public function testChangeColor() { - $categoryModel = new Category($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $categoryModel = new CategoryModel($this->container); + $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'))); @@ -30,7 +30,7 @@ class TaskAssignColorPriorityTest extends Base $action->setParam('color_id', 'red'); $action->setParam('priority', 1); - $this->assertTrue($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -39,8 +39,8 @@ class TaskAssignColorPriorityTest extends Base public function testWithWrongPriority() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -52,6 +52,6 @@ class TaskAssignColorPriorityTest extends Base $action->setParam('color_id', 'red'); $action->setParam('priority', 1); - $this->assertFalse($action->execute($event, Task::EVENT_CREATE_UPDATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CREATE_UPDATE)); } } diff --git a/tests/units/Action/TaskAssignColorUserTest.php b/tests/units/Action/TaskAssignColorUserTest.php index 76e2282c..370f9070 100644 --- a/tests/units/Action/TaskAssignColorUserTest.php +++ b/tests/units/Action/TaskAssignColorUserTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignColorUser; class TaskAssignColorUserTest extends Base { public function testChangeColor() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -27,7 +27,7 @@ class TaskAssignColorUserTest extends Base $action->setParam('color_id', 'red'); $action->setParam('user_id', 1); - $this->assertTrue($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -36,8 +36,8 @@ class TaskAssignColorUserTest extends Base public function testWithWrongUser() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -49,6 +49,6 @@ class TaskAssignColorUserTest extends Base $action->setParam('color_id', 'red'); $action->setParam('user_id', 1); - $this->assertFalse($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); } } diff --git a/tests/units/Action/TaskAssignCurrentUserColumnTest.php b/tests/units/Action/TaskAssignCurrentUserColumnTest.php index a741076b..6fdbda63 100644 --- a/tests/units/Action/TaskAssignCurrentUserColumnTest.php +++ b/tests/units/Action/TaskAssignCurrentUserColumnTest.php @@ -3,10 +3,10 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignCurrentUserColumn; class TaskAssignCurrentUserColumnTest extends Base @@ -15,9 +15,9 @@ class TaskAssignCurrentUserColumnTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -28,7 +28,7 @@ class TaskAssignCurrentUserColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -39,8 +39,8 @@ class TaskAssignCurrentUserColumnTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -51,13 +51,13 @@ class TaskAssignCurrentUserColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } public function testWithNoUserSession() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -68,6 +68,6 @@ class TaskAssignCurrentUserColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Action/TaskAssignCurrentUserTest.php b/tests/units/Action/TaskAssignCurrentUserTest.php index 2f4b235f..5569a191 100644 --- a/tests/units/Action/TaskAssignCurrentUserTest.php +++ b/tests/units/Action/TaskAssignCurrentUserTest.php @@ -3,10 +3,10 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignCurrentUser; class TaskAssignCurrentUserTest extends Base @@ -15,9 +15,9 @@ class TaskAssignCurrentUserTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -27,7 +27,7 @@ class TaskAssignCurrentUserTest extends Base $action = new TaskAssignCurrentUser($this->container); $action->setProjectId(1); - $this->assertTrue($action->execute($event, Task::EVENT_CREATE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CREATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -36,8 +36,8 @@ class TaskAssignCurrentUserTest extends Base public function testWithNoUserSession() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -47,6 +47,6 @@ class TaskAssignCurrentUserTest extends Base $action = new TaskAssignCurrentUser($this->container); $action->setProjectId(1); - $this->assertFalse($action->execute($event, Task::EVENT_CREATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CREATE)); } } diff --git a/tests/units/Action/TaskAssignSpecificUserTest.php b/tests/units/Action/TaskAssignSpecificUserTest.php index 7741e983..78ec314f 100644 --- a/tests/units/Action/TaskAssignSpecificUserTest.php +++ b/tests/units/Action/TaskAssignSpecificUserTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskAssignSpecificUser; class TaskAssignSpecificUserTest extends Base { public function testChangeUser() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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))); @@ -27,7 +27,7 @@ class TaskAssignSpecificUserTest extends Base $action->setParam('column_id', 2); $action->setParam('user_id', 1); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -36,8 +36,8 @@ class TaskAssignSpecificUserTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -49,6 +49,6 @@ class TaskAssignSpecificUserTest extends Base $action->setParam('column_id', 2); $action->setParam('user_id', 1); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Action/TaskAssignUserTest.php b/tests/units/Action/TaskAssignUserTest.php index d723ed2b..060128eb 100644 --- a/tests/units/Action/TaskAssignUserTest.php +++ b/tests/units/Action/TaskAssignUserTest.php @@ -3,11 +3,11 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\User; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\UserModel; use Kanboard\Action\TaskAssignUser; use Kanboard\Core\Security\Role; @@ -15,11 +15,11 @@ class TaskAssignUserTest extends Base { public function testChangeUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($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))); @@ -41,8 +41,8 @@ class TaskAssignUserTest extends Base public function testWithNotAssignableUser() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); diff --git a/tests/units/Action/TaskCloseColumnTest.php b/tests/units/Action/TaskCloseColumnTest.php index 654aeec1..f9a938f0 100644 --- a/tests/units/Action/TaskCloseColumnTest.php +++ b/tests/units/Action/TaskCloseColumnTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskCloseColumn; class TaskCloseColumnTest extends Base { public function testClose() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -26,7 +26,7 @@ class TaskCloseColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -35,8 +35,8 @@ class TaskCloseColumnTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -47,6 +47,6 @@ class TaskCloseColumnTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Action/TaskCloseNoActivityTest.php b/tests/units/Action/TaskCloseNoActivityTest.php index b6e04c47..707d8585 100644 --- a/tests/units/Action/TaskCloseNoActivityTest.php +++ b/tests/units/Action/TaskCloseNoActivityTest.php @@ -3,25 +3,25 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\TaskListEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskCloseNoActivity; class TaskCloseNoActivityTest extends Base { public function testClose() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); $tasks = $taskFinderModel->getAll(1); $event = new TaskListEvent(array('tasks' => $tasks, 'project_id' => 1)); @@ -30,7 +30,7 @@ class TaskCloseNoActivityTest extends Base $action->setProjectId(1); $action->setParam('duration', 2); - $this->assertTrue($action->execute($event, Task::EVENT_DAILY_CRONJOB)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); diff --git a/tests/units/Action/TaskCloseTest.php b/tests/units/Action/TaskCloseTest.php index 536d79ca..3df10cb8 100644 --- a/tests/units/Action/TaskCloseTest.php +++ b/tests/units/Action/TaskCloseTest.php @@ -3,18 +3,18 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskClose; class TaskCloseTest extends Base { public function testClose() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -34,8 +34,8 @@ class TaskCloseTest extends Base public function testWithNoTaskId() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); diff --git a/tests/units/Action/TaskCreationTest.php b/tests/units/Action/TaskCreationTest.php index 57a3ee46..fb3d334f 100644 --- a/tests/units/Action/TaskCreationTest.php +++ b/tests/units/Action/TaskCreationTest.php @@ -3,16 +3,16 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskCreation as TaskCreationAction; class TaskCreationActionTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskFinderModel = new TaskFinder($this->container); + $projectModel = new ProjectModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -33,7 +33,7 @@ class TaskCreationActionTest extends Base public function testWithNoTitle() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); diff --git a/tests/units/Action/TaskDuplicateAnotherProjectTest.php b/tests/units/Action/TaskDuplicateAnotherProjectTest.php index d5f99ec9..98ff187f 100644 --- a/tests/units/Action/TaskDuplicateAnotherProjectTest.php +++ b/tests/units/Action/TaskDuplicateAnotherProjectTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskDuplicateAnotherProject; class TaskDuplicateAnotherProjectTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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(2, $projectModel->create(array('name' => 'test2'))); @@ -28,7 +28,7 @@ class TaskDuplicateAnotherProjectTest extends Base $action->setParam('project_id', 2); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_CLOSE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CLOSE)); $task = $taskFinderModel->getById(2); $this->assertNotEmpty($task); @@ -38,7 +38,7 @@ class TaskDuplicateAnotherProjectTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -50,6 +50,6 @@ class TaskDuplicateAnotherProjectTest extends Base $action->setParam('project_id', 2); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_CLOSE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CLOSE)); } } diff --git a/tests/units/Action/TaskEmailNoActivityTest.php b/tests/units/Action/TaskEmailNoActivityTest.php index af4baed5..c4d489d8 100644 --- a/tests/units/Action/TaskEmailNoActivityTest.php +++ b/tests/units/Action/TaskEmailNoActivityTest.php @@ -3,28 +3,28 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\TaskListEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; -use Kanboard\Model\User; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\UserModel; use Kanboard\Action\TaskEmailNoActivity; class TaskEmailNoActivityTest extends Base { public function testSendEmail() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'test', 'email' => 'chuck@norris', 'name' => 'Chuck Norris'))); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); $tasks = $taskFinderModel->getAll(1); $event = new TaskListEvent(array('tasks' => $tasks, 'project_id' => 1)); @@ -40,22 +40,22 @@ class TaskEmailNoActivityTest extends Base ->method('send') ->with('chuck@norris', 'Chuck Norris', 'Old tasks', $this->anything()); - $this->assertTrue($action->execute($event, Task::EVENT_DAILY_CRONJOB)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); } public function testUserWithNoEmail() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'test', 'name' => 'Chuck Norris'))); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_modification' => strtotime('-10days'))); $tasks = $taskFinderModel->getAll(1); $event = new TaskListEvent(array('tasks' => $tasks, 'project_id' => 1)); @@ -70,15 +70,15 @@ class TaskEmailNoActivityTest extends Base ->expects($this->never()) ->method('send'); - $this->assertFalse($action->execute($event, Task::EVENT_DAILY_CRONJOB)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); } public function testTooRecent() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'test', 'email' => 'chuck@norris', 'name' => 'Chuck Norris'))); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -98,6 +98,6 @@ class TaskEmailNoActivityTest extends Base ->expects($this->never()) ->method('send'); - $this->assertFalse($action->execute($event, Task::EVENT_DAILY_CRONJOB)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); } } diff --git a/tests/units/Action/TaskEmailTest.php b/tests/units/Action/TaskEmailTest.php index 93b7b559..df71aaf8 100644 --- a/tests/units/Action/TaskEmailTest.php +++ b/tests/units/Action/TaskEmailTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\User; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; use Kanboard\Action\TaskEmail; class TaskEmailTest extends Base { public function testSuccess() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $userModel = new UserModel($this->container); + $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'))); @@ -38,12 +38,12 @@ class TaskEmailTest extends Base $this->stringContains('test') ); - $this->assertTrue($action->execute($event, Task::EVENT_CLOSE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CLOSE)); } public function testWithWrongColumn() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -55,6 +55,6 @@ class TaskEmailTest extends Base $action->setParam('user_id', 1); $action->setParam('subject', 'My email subject'); - $this->assertFalse($action->execute($event, Task::EVENT_CLOSE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CLOSE)); } } diff --git a/tests/units/Action/TaskMoveAnotherProjectTest.php b/tests/units/Action/TaskMoveAnotherProjectTest.php index ec48f0a4..d36df47b 100644 --- a/tests/units/Action/TaskMoveAnotherProjectTest.php +++ b/tests/units/Action/TaskMoveAnotherProjectTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskMoveAnotherProject; class TaskMoveAnotherProjectTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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(2, $projectModel->create(array('name' => 'test2'))); @@ -28,7 +28,7 @@ class TaskMoveAnotherProjectTest extends Base $action->setParam('project_id', 2); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_CLOSE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_CLOSE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -39,7 +39,7 @@ class TaskMoveAnotherProjectTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -51,6 +51,6 @@ class TaskMoveAnotherProjectTest extends Base $action->setParam('project_id', 2); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_CLOSE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_CLOSE)); } } diff --git a/tests/units/Action/TaskMoveColumnAssignedTest.php b/tests/units/Action/TaskMoveColumnAssignedTest.php index 3b325505..f8982969 100644 --- a/tests/units/Action/TaskMoveColumnAssignedTest.php +++ b/tests/units/Action/TaskMoveColumnAssignedTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskMoveColumnAssigned; class TaskMoveColumnAssignedTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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(2, $projectModel->create(array('name' => 'test2'))); @@ -28,7 +28,7 @@ class TaskMoveColumnAssignedTest extends Base $action->setParam('src_column_id', 1); $action->setParam('dest_column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -38,7 +38,7 @@ class TaskMoveColumnAssignedTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -50,6 +50,6 @@ class TaskMoveColumnAssignedTest extends Base $action->setParam('src_column_id', 1); $action->setParam('dest_column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); } } diff --git a/tests/units/Action/TaskMoveColumnCategoryChangeTest.php b/tests/units/Action/TaskMoveColumnCategoryChangeTest.php index 8783c679..c42383f8 100644 --- a/tests/units/Action/TaskMoveColumnCategoryChangeTest.php +++ b/tests/units/Action/TaskMoveColumnCategoryChangeTest.php @@ -3,21 +3,21 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Category; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskMoveColumnCategoryChange; class TaskMoveColumnCategoryChangeTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -31,7 +31,7 @@ class TaskMoveColumnCategoryChangeTest extends Base $action->setParam('category_id', 1); $action->setParam('dest_column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_UPDATE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_UPDATE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -41,9 +41,9 @@ class TaskMoveColumnCategoryChangeTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -57,14 +57,14 @@ class TaskMoveColumnCategoryChangeTest extends Base $action->setParam('category_id', 1); $action->setParam('dest_column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_UPDATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_UPDATE)); } public function testWithWrongCategory() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -79,6 +79,6 @@ class TaskMoveColumnCategoryChangeTest extends Base $action->setParam('category_id', 1); $action->setParam('dest_column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_UPDATE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_UPDATE)); } } diff --git a/tests/units/Action/TaskMoveColumnUnAssignedTest.php b/tests/units/Action/TaskMoveColumnUnAssignedTest.php index cf2333cc..befae36b 100644 --- a/tests/units/Action/TaskMoveColumnUnAssignedTest.php +++ b/tests/units/Action/TaskMoveColumnUnAssignedTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskMoveColumnUnAssigned; class TaskMoveColumnUnAssignedTest extends Base { public function testSuccess() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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(2, $projectModel->create(array('name' => 'test2'))); @@ -28,7 +28,7 @@ class TaskMoveColumnUnAssignedTest extends Base $action->setParam('src_column_id', 1); $action->setParam('dest_column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -38,7 +38,7 @@ class TaskMoveColumnUnAssignedTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -50,12 +50,12 @@ class TaskMoveColumnUnAssignedTest extends Base $action->setParam('src_column_id', 1); $action->setParam('dest_column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); } public function testWithWrongUser() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -67,6 +67,6 @@ class TaskMoveColumnUnAssignedTest extends Base $action->setParam('src_column_id', 1); $action->setParam('dest_column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_ASSIGNEE_CHANGE)); } } diff --git a/tests/units/Action/TaskOpenTest.php b/tests/units/Action/TaskOpenTest.php index 01290a64..1018e2ea 100644 --- a/tests/units/Action/TaskOpenTest.php +++ b/tests/units/Action/TaskOpenTest.php @@ -3,18 +3,18 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; use Kanboard\Action\TaskOpen; class TaskOpenTest extends Base { public function testClose() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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', 'is_active' => 0))); @@ -34,8 +34,8 @@ class TaskOpenTest extends Base public function testWithNoTaskId() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); diff --git a/tests/units/Action/TaskUpdateStartDateTest.php b/tests/units/Action/TaskUpdateStartDateTest.php index adf5bd9d..ddd9eafd 100644 --- a/tests/units/Action/TaskUpdateStartDateTest.php +++ b/tests/units/Action/TaskUpdateStartDateTest.php @@ -3,19 +3,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Action\TaskUpdateStartDate; class TaskUpdateStartDateTest extends Base { public function testClose() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $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'))); @@ -26,7 +26,7 @@ class TaskUpdateStartDateTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); $task = $taskFinderModel->getById(1); $this->assertNotEmpty($task); @@ -35,8 +35,8 @@ class TaskUpdateStartDateTest extends Base public function testWithWrongColumn() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $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'))); @@ -47,6 +47,6 @@ class TaskUpdateStartDateTest extends Base $action->setProjectId(1); $action->setParam('column_id', 2); - $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN)); + $this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN)); } } diff --git a/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php b/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php index b87e9573..831ec960 100644 --- a/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php +++ b/tests/units/Analytic/AverageLeadCycleTimeAnalyticTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Analytic\AverageLeadCycleTimeAnalytic; class AverageLeadCycleTimeAnalyticTest extends Base { public function testBuild() { - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $averageLeadCycleTimeAnalytic = new AverageLeadCycleTimeAnalytic($this->container); $now = time(); @@ -26,19 +26,19 @@ class AverageLeadCycleTimeAnalyticTest extends Base $this->assertEquals(5, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); // LT=3600 CT=1800 - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600, 'date_started' => $now + 1800)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600, 'date_started' => $now + 1800)); // LT=1800 CT=900 - $this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800, 'date_started' => $now + 900)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800, 'date_started' => $now + 900)); // LT=3600 CT=0 - $this->container['db']->table(Task::TABLE)->eq('id', 3)->update(array('date_completed' => $now + 3600)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 3)->update(array('date_completed' => $now + 3600)); // LT=2*3600 CT=0 - $this->container['db']->table(Task::TABLE)->eq('id', 4)->update(array('date_completed' => $now + 2 * 3600)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 4)->update(array('date_completed' => $now + 2 * 3600)); // CT=0 - $this->container['db']->table(Task::TABLE)->eq('id', 5)->update(array('date_started' => $now + 900)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 5)->update(array('date_started' => $now + 900)); $stats = $averageLeadCycleTimeAnalytic->build(1); @@ -51,7 +51,7 @@ class AverageLeadCycleTimeAnalyticTest extends Base public function testBuildWithNoTasks() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $averageLeadCycleTimeAnalytic = new AverageLeadCycleTimeAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); diff --git a/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php b/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php index 4e01bfa9..1da425fb 100644 --- a/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php +++ b/tests/units/Analytic/AverageTimeSpentColumnAnalyticTest.php @@ -2,19 +2,19 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\Transition; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TransitionModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; use Kanboard\Analytic\AverageTimeSpentColumnAnalytic; class AverageTimeSpentColumnAnalyticTest extends Base { public function testAverageWithNoTransitions() { - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $averageLeadCycleTimeAnalytic = new AverageTimeSpentColumnAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -24,8 +24,8 @@ class AverageTimeSpentColumnAnalyticTest extends Base $now = time(); - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600)); - $this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800)); $stats = $averageLeadCycleTimeAnalytic->build(1); @@ -52,10 +52,10 @@ class AverageTimeSpentColumnAnalyticTest extends Base public function testAverageWithTransitions() { - $transitionModel = new Transition($this->container); - $taskFinderModel = new TaskFinder($this->container); - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $transitionModel = new TransitionModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $averageLeadCycleTimeAnalytic = new AverageTimeSpentColumnAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -64,8 +64,8 @@ class AverageTimeSpentColumnAnalyticTest extends Base $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); $now = time(); - $this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600)); - $this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600)); + $this->container['db']->table(TaskModel::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800)); foreach (array(1, 2) as $task_id) { $task = $taskFinderModel->getById($task_id); diff --git a/tests/units/Analytic/EstimatedTimeComparisonAnalyticTest.php b/tests/units/Analytic/EstimatedTimeComparisonAnalyticTest.php index 2ca631b1..29bf88a3 100644 --- a/tests/units/Analytic/EstimatedTimeComparisonAnalyticTest.php +++ b/tests/units/Analytic/EstimatedTimeComparisonAnalyticTest.php @@ -2,16 +2,16 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Analytic\EstimatedTimeComparisonAnalytic; class EstimatedTimeComparisonAnalyticTest extends Base { public function testBuild() { - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $estimatedTimeComparisonAnalytic = new EstimatedTimeComparisonAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -41,8 +41,8 @@ class EstimatedTimeComparisonAnalyticTest extends Base public function testBuildWithNoClosedTask() { - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $estimatedTimeComparisonAnalytic = new EstimatedTimeComparisonAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -70,8 +70,8 @@ class EstimatedTimeComparisonAnalyticTest extends Base public function testBuildWithOnlyClosedTask() { - $taskCreationModel = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); $estimatedTimeComparisonAnalytic = new EstimatedTimeComparisonAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); diff --git a/tests/units/Analytic/TaskDistributionAnalyticTest.php b/tests/units/Analytic/TaskDistributionAnalyticTest.php index 531101ef..0d600b8b 100644 --- a/tests/units/Analytic/TaskDistributionAnalyticTest.php +++ b/tests/units/Analytic/TaskDistributionAnalyticTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Analytic\TaskDistributionAnalytic; class TaskDistributionAnalyticTest extends Base { public function testBuild() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $taskDistributionModel = new TaskDistributionAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -49,7 +49,7 @@ class TaskDistributionAnalyticTest extends Base private function createTasks($column_id, $nb_active, $nb_inactive) { - $taskCreationModel = new TaskCreation($this->container); + $taskCreationModel = new TaskCreationModel($this->container); for ($i = 0; $i < $nb_active; $i++) { $this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => $column_id, 'is_active' => 1))); diff --git a/tests/units/Analytic/UserDistributionAnalyticTest.php b/tests/units/Analytic/UserDistributionAnalyticTest.php index bdc136e1..f4514899 100644 --- a/tests/units/Analytic/UserDistributionAnalyticTest.php +++ b/tests/units/Analytic/UserDistributionAnalyticTest.php @@ -2,10 +2,10 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\User; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\UserModel; use Kanboard\Analytic\UserDistributionAnalytic; use Kanboard\Core\Security\Role; @@ -13,9 +13,9 @@ class UserDistributionAnalyticTest extends Base { public function testBuild() { - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); $userDistributionModel = new UserDistributionAnalytic($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); @@ -70,7 +70,7 @@ class UserDistributionAnalyticTest extends Base private function createTasks($user_id, $nb_active, $nb_inactive) { - $taskCreationModel = new TaskCreation($this->container); + $taskCreationModel = new TaskCreationModel($this->container); for ($i = 0; $i < $nb_active; $i++) { $this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => $user_id, 'is_active' => 1))); diff --git a/tests/units/Auth/DatabaseAuthTest.php b/tests/units/Auth/DatabaseAuthTest.php index ac099a7e..97c75bd2 100644 --- a/tests/units/Auth/DatabaseAuthTest.php +++ b/tests/units/Auth/DatabaseAuthTest.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Auth\DatabaseAuth; -use Kanboard\Model\User; +use Kanboard\Model\UserModel; class DatabaseAuthTest extends Base { @@ -41,7 +41,7 @@ class DatabaseAuthTest extends Base public function testIsvalidSession() { - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $provider = new DatabaseAuth($this->container); $this->assertFalse($provider->isValidSession()); diff --git a/tests/units/Base.php b/tests/units/Base.php index 16c34573..c7e066d1 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -63,8 +63,8 @@ abstract class Base extends PHPUnit_Framework_TestCase ->setMethods(array('send')) ->getMock(); - $this->container['userNotificationType'] = $this - ->getMockBuilder('\Kanboard\Model\UserNotificationType') + $this->container['userNotificationTypeModel'] = $this + ->getMockBuilder('\Kanboard\Model\UserNotificationTypeModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('getType', 'getSelectedTypes')) ->getMock(); diff --git a/tests/units/Core/Action/ActionManagerTest.php b/tests/units/Core/Action/ActionManagerTest.php index aae5bd2d..e7c2071f 100644 --- a/tests/units/Core/Action/ActionManagerTest.php +++ b/tests/units/Core/Action/ActionManagerTest.php @@ -7,10 +7,10 @@ use Kanboard\Action\TaskAssignColorColumn; use Kanboard\Action\TaskClose; use Kanboard\Action\TaskCloseColumn; use Kanboard\Action\TaskUpdateStartDate; -use Kanboard\Model\Action; -use Kanboard\Model\Task; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; +use Kanboard\Model\ActionModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; use Kanboard\Core\Security\Role; class ActionManagerTest extends Base @@ -79,16 +79,16 @@ class ActionManagerTest extends Base $events = $actionManager->getCompatibleEvents('\\'.get_class($actionTaskAssignColorColumn)); $this->assertCount(2, $events); - $this->assertArrayHasKey(Task::EVENT_CREATE, $events); - $this->assertArrayHasKey(Task::EVENT_MOVE_COLUMN, $events); - $this->assertNotEmpty($events[Task::EVENT_CREATE]); - $this->assertNotEmpty($events[Task::EVENT_MOVE_COLUMN]); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE, $events); + $this->assertArrayHasKey(TaskModel::EVENT_MOVE_COLUMN, $events); + $this->assertNotEmpty($events[TaskModel::EVENT_CREATE]); + $this->assertNotEmpty($events[TaskModel::EVENT_MOVE_COLUMN]); } public function testAttachEventsWithoutUserSession() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container); $actionManager = new ActionManager($this->container); $actionManager->register($actionTaskAssignColorColumn); @@ -101,13 +101,13 @@ class ActionManagerTest extends Base $this->assertEquals(1, $projectModel->create(array('name' =>'test'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(Task::EVENT_CREATE); + $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_CREATE); $this->assertCount(1, $listeners); $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]); @@ -118,9 +118,9 @@ class ActionManagerTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $actionModel = new ActionModel($this->container); $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container); $actionManager = new ActionManager($this->container); $actionManager->register($actionTaskAssignColorColumn); @@ -134,21 +134,21 @@ class ActionManagerTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 2, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(Task::EVENT_MOVE_COLUMN); + $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_MOVE_COLUMN); $this->assertCount(1, $listeners); $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]); @@ -157,9 +157,9 @@ class ActionManagerTest extends Base public function testThatEachListenerAreDifferentInstance() { - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $actionModel = new ActionModel($this->container); $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container); $actionManager = new ActionManager($this->container); $actionManager->register($actionTaskAssignColorColumn); @@ -169,21 +169,21 @@ class ActionManagerTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => key($actions), 'params' => array('column_id' => 2, 'color_id' => 'green'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(Task::EVENT_MOVE_COLUMN); + $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_MOVE_COLUMN); $this->assertCount(2, $listeners); $this->assertFalse($listeners[0][0] === $listeners[1][0]); diff --git a/tests/units/Core/Filter/LexerBuilderTest.php b/tests/units/Core/Filter/LexerBuilderTest.php index ac5315bb..23726f32 100644 --- a/tests/units/Core/Filter/LexerBuilderTest.php +++ b/tests/units/Core/Filter/LexerBuilderTest.php @@ -5,17 +5,17 @@ require_once __DIR__.'/../../Base.php'; use Kanboard\Core\Filter\LexerBuilder; use Kanboard\Filter\TaskAssigneeFilter; use Kanboard\Filter\TaskTitleFilter; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; class LexerBuilderTest extends Base { public function testBuilderThatReturnResult() { - $project = new Project($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); + $project = new ProjectModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $project->create(array('name' => 'Project'))); @@ -33,9 +33,9 @@ class LexerBuilderTest extends Base public function testBuilderThatReturnNothing() { - $project = new Project($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); + $project = new ProjectModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $project->create(array('name' => 'Project'))); @@ -52,9 +52,9 @@ class LexerBuilderTest extends Base public function testBuilderWithEmptyInput() { - $project = new Project($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); + $project = new ProjectModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $project->create(array('name' => 'Project'))); @@ -71,9 +71,9 @@ class LexerBuilderTest extends Base public function testBuilderWithMultipleMatches() { - $project = new Project($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); + $project = new ProjectModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $project->create(array('name' => 'Project'))); @@ -91,7 +91,7 @@ class LexerBuilderTest extends Base public function testClone() { - $taskFinder = new TaskFinder($this->container); + $taskFinder = new TaskFinderModel($this->container); $query = $taskFinder->getExtendedQuery(); $builder = new LexerBuilder(); diff --git a/tests/units/Core/Filter/OrCriteriaTest.php b/tests/units/Core/Filter/OrCriteriaTest.php index 787d3461..a46726c3 100644 --- a/tests/units/Core/Filter/OrCriteriaTest.php +++ b/tests/units/Core/Filter/OrCriteriaTest.php @@ -3,10 +3,10 @@ use Kanboard\Core\Filter\OrCriteria; use Kanboard\Filter\TaskAssigneeFilter; use Kanboard\Filter\TaskTitleFilter; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\User; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\UserModel; require_once __DIR__.'/../../Base.php'; @@ -14,10 +14,10 @@ class OrCriteriaTest extends Base { public function testWithSameFilter() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar'))); @@ -36,10 +36,10 @@ class OrCriteriaTest extends Base public function testWithDifferentFilter() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar'))); diff --git a/tests/units/Core/Group/GroupManagerTest.php b/tests/units/Core/Group/GroupManagerTest.php index faf5501f..e89ad15b 100644 --- a/tests/units/Core/Group/GroupManagerTest.php +++ b/tests/units/Core/Group/GroupManagerTest.php @@ -2,7 +2,7 @@ require_once __DIR__.'/../../Base.php'; -use Kanboard\Model\Group; +use Kanboard\Model\GroupModel; use Kanboard\Core\Group\GroupManager; use Kanboard\Group\DatabaseBackendGroupProvider; @@ -10,7 +10,7 @@ class GroupManagerTest extends Base { public function testFind() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $groupManager = new GroupManager; $this->assertEquals(1, $groupModel->create('Group 1')); diff --git a/tests/units/Core/User/GroupSyncTest.php b/tests/units/Core/User/GroupSyncTest.php index decb2fdc..d3df71bb 100644 --- a/tests/units/Core/User/GroupSyncTest.php +++ b/tests/units/Core/User/GroupSyncTest.php @@ -3,15 +3,15 @@ require_once __DIR__.'/../../Base.php'; use Kanboard\Core\User\GroupSync; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; class GroupSyncTest extends Base { public function testAddGroups() { - $group = new Group($this->container); - $groupMember = new GroupMember($this->container); + $group = new GroupModel($this->container); + $groupMember = new GroupMemberModel($this->container); $groupSync = new GroupSync($this->container); $this->assertEquals(1, $group->create('My Group 1', 'externalId1')); @@ -30,8 +30,8 @@ class GroupSyncTest extends Base public function testRemoveGroups() { - $group = new Group($this->container); - $groupMember = new GroupMember($this->container); + $group = new GroupModel($this->container); + $groupMember = new GroupMemberModel($this->container); $groupSync = new GroupSync($this->container); $this->assertEquals(1, $group->create('My Group 1', 'externalId1')); @@ -50,8 +50,8 @@ class GroupSyncTest extends Base public function testBoth() { - $group = new Group($this->container); - $groupMember = new GroupMember($this->container); + $group = new GroupModel($this->container); + $groupMember = new GroupMemberModel($this->container); $groupSync = new GroupSync($this->container); $this->assertEquals(1, $group->create('My Group 1', 'externalId1')); @@ -74,8 +74,8 @@ class GroupSyncTest extends Base public function testThatInternalGroupsAreNotTouched() { - $group = new Group($this->container); - $groupMember = new GroupMember($this->container); + $group = new GroupModel($this->container); + $groupMember = new GroupMemberModel($this->container); $groupSync = new GroupSync($this->container); $this->assertEquals(1, $group->create('My Group 1')); diff --git a/tests/units/Export/TaskExportTest.php b/tests/units/Export/TaskExportTest.php index f0637c25..c142cde9 100644 --- a/tests/units/Export/TaskExportTest.php +++ b/tests/units/Export/TaskExportTest.php @@ -2,21 +2,21 @@ require_once __DIR__ . '/../Base.php'; -use Kanboard\Model\TaskCreation; +use Kanboard\Model\TaskCreationModel; use Kanboard\Export\TaskExport; -use Kanboard\Model\Project; -use Kanboard\Model\Category; -use Kanboard\Model\Swimlane; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\SwimlaneModel; class TaskExportTest extends Base { public function testExport() { - $tc = new TaskCreation($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); $e = new TaskExport($this->container); - $s = new Swimlane($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Export Project'))); diff --git a/tests/units/Export/TransitionExportTest.php b/tests/units/Export/TransitionExportTest.php index 7ff3082e..ee195ad1 100644 --- a/tests/units/Export/TransitionExportTest.php +++ b/tests/units/Export/TransitionExportTest.php @@ -2,18 +2,18 @@ require_once __DIR__ . '/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Transition; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TransitionModel; use Kanboard\Export\TransitionExport; -use Kanboard\Model\Project; +use Kanboard\Model\ProjectModel; class TransitionExportTest extends Base { public function testExport() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $transitionModel = new Transition($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $transitionModel = new TransitionModel($this->container); $transitionExportModel = new TransitionExport($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); diff --git a/tests/units/Filter/ProjectActivityCreationDateFilterTest.php b/tests/units/Filter/ProjectActivityCreationDateFilterTest.php index 1dce4451..716d58bd 100644 --- a/tests/units/Filter/ProjectActivityCreationDateFilterTest.php +++ b/tests/units/Filter/ProjectActivityCreationDateFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityCreationDateFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,14 +13,14 @@ class ProjectActivityCreationDateFilterTest extends Base { public function testWithToday() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreationDateFilter('today'); @@ -33,14 +33,14 @@ class ProjectActivityCreationDateFilterTest extends Base public function testWithYesterday() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreationDateFilter('yesterday'); @@ -53,14 +53,14 @@ class ProjectActivityCreationDateFilterTest extends Base public function testWithStrtotimeString() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreationDateFilter('<=last week'); @@ -73,14 +73,14 @@ class ProjectActivityCreationDateFilterTest extends Base public function testWithIsoDate() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreationDateFilter(date('Y-m-d')); @@ -93,14 +93,14 @@ class ProjectActivityCreationDateFilterTest extends Base public function testWithOperatorAndIsoDate() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreationDateFilter('>='.date('Y-m-d')); diff --git a/tests/units/Filter/ProjectActivityCreatorFilterTest.php b/tests/units/Filter/ProjectActivityCreatorFilterTest.php index 99c70322..65281d06 100644 --- a/tests/units/Filter/ProjectActivityCreatorFilterTest.php +++ b/tests/units/Filter/ProjectActivityCreatorFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityCreatorFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,14 +13,14 @@ class ProjectActivityCreatorFilterTest extends Base { public function testWithUsername() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreatorFilter('admin'); @@ -32,14 +32,14 @@ class ProjectActivityCreatorFilterTest extends Base public function testWithAnotherUsername() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreatorFilter('John Doe'); @@ -51,14 +51,14 @@ class ProjectActivityCreatorFilterTest extends Base public function testWithCurrentUser() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreatorFilter('me'); @@ -71,14 +71,14 @@ class ProjectActivityCreatorFilterTest extends Base public function testWithAnotherCurrentUser() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); $query = $projectActivityModel->getQuery(); $filter = new ProjectActivityCreatorFilter('me'); diff --git a/tests/units/Filter/ProjectActivityProjectIdFilterTest.php b/tests/units/Filter/ProjectActivityProjectIdFilterTest.php index 193852e1..75e6fa70 100644 --- a/tests/units/Filter/ProjectActivityProjectIdFilterTest.php +++ b/tests/units/Filter/ProjectActivityProjectIdFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityProjectIdFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityProjectIdFilterTest extends Base { public function testFilterByProjectId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -25,8 +25,8 @@ class ProjectActivityProjectIdFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 2))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityProjectIdFilter(1); $filter->withQuery($query)->apply(); diff --git a/tests/units/Filter/ProjectActivityProjectIdsFilterTest.php b/tests/units/Filter/ProjectActivityProjectIdsFilterTest.php index e99d2e2f..b5c4683d 100644 --- a/tests/units/Filter/ProjectActivityProjectIdsFilterTest.php +++ b/tests/units/Filter/ProjectActivityProjectIdsFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityProjectIdsFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityProjectIdsFilterTest extends Base { public function testFilterByProjectIds() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -27,9 +27,9 @@ class ProjectActivityProjectIdsFilterTest extends Base $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 2))); $this->assertEquals(3, $taskCreation->create(array('title' => 'Test', 'project_id' => 3))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); - $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); $filter = new ProjectActivityProjectIdsFilter(array(1, 2)); $filter->withQuery($query)->apply(); @@ -38,10 +38,10 @@ class ProjectActivityProjectIdsFilterTest extends Base public function testWithEmptyArgument() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -52,9 +52,9 @@ class ProjectActivityProjectIdsFilterTest extends Base $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 2))); $this->assertEquals(3, $taskCreation->create(array('title' => 'Test', 'project_id' => 3))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, $taskFinder->getById(1))); - $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, Task::EVENT_CREATE, $taskFinder->getById(2))); - $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, Task::EVENT_CREATE, $taskFinder->getById(3))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, $taskFinder->getById(1))); + $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, TaskModel::EVENT_CREATE, $taskFinder->getById(2))); + $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, TaskModel::EVENT_CREATE, $taskFinder->getById(3))); $filter = new ProjectActivityProjectIdsFilter(array()); $filter->withQuery($query)->apply(); diff --git a/tests/units/Filter/ProjectActivityProjectNameFilterTest.php b/tests/units/Filter/ProjectActivityProjectNameFilterTest.php index de9d7d59..3ec01bc0 100644 --- a/tests/units/Filter/ProjectActivityProjectNameFilterTest.php +++ b/tests/units/Filter/ProjectActivityProjectNameFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityProjectNameFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityProjectNameFilterTest extends Base { public function testFilterByProjectName() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -25,8 +25,8 @@ class ProjectActivityProjectNameFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 2))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityProjectNameFilter('P1'); $filter->withQuery($query)->apply(); diff --git a/tests/units/Filter/ProjectActivityTaskIdFilterTest.php b/tests/units/Filter/ProjectActivityTaskIdFilterTest.php index 646cab1b..940d1c6f 100644 --- a/tests/units/Filter/ProjectActivityTaskIdFilterTest.php +++ b/tests/units/Filter/ProjectActivityTaskIdFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityTaskIdFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityTaskIdFilterTest extends Base { public function testFilterByTaskId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -24,8 +24,8 @@ class ProjectActivityTaskIdFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityTaskIdFilter(1); $filter->withQuery($query)->apply(); diff --git a/tests/units/Filter/ProjectActivityTaskStatusFilterTest.php b/tests/units/Filter/ProjectActivityTaskStatusFilterTest.php index b8df6338..673a4990 100644 --- a/tests/units/Filter/ProjectActivityTaskStatusFilterTest.php +++ b/tests/units/Filter/ProjectActivityTaskStatusFilterTest.php @@ -1,12 +1,12 @@ <?php use Kanboard\Filter\ProjectActivityTaskStatusFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; -use Kanboard\Model\TaskStatus; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskStatusModel; require_once __DIR__.'/../Base.php'; @@ -14,19 +14,19 @@ class ProjectActivityTaskStatusFilterTest extends Base { public function testFilterByTaskStatus() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $taskStatus = new TaskStatus($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskStatus = new TaskStatusModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $this->assertTrue($taskStatus->close(1)); diff --git a/tests/units/Filter/ProjectActivityTaskTitleFilterTest.php b/tests/units/Filter/ProjectActivityTaskTitleFilterTest.php index 925a1ab2..f6217dba 100644 --- a/tests/units/Filter/ProjectActivityTaskTitleFilterTest.php +++ b/tests/units/Filter/ProjectActivityTaskTitleFilterTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Filter\ProjectActivityTaskTitleFilter; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Task; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityTaskTitleFilterTest extends Base { public function testWithFullTitle() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -24,8 +24,8 @@ class ProjectActivityTaskTitleFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test1', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test2', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityTaskTitleFilter('test2'); $filter->withQuery($query)->apply(); @@ -34,10 +34,10 @@ class ProjectActivityTaskTitleFilterTest extends Base public function testWithPartialTitle() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -45,8 +45,8 @@ class ProjectActivityTaskTitleFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test1', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test2', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityTaskTitleFilter('test'); $filter->withQuery($query)->apply(); @@ -55,10 +55,10 @@ class ProjectActivityTaskTitleFilterTest extends Base public function testWithId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $query = $projectActivityModel->getQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -66,8 +66,8 @@ class ProjectActivityTaskTitleFilterTest extends Base $this->assertEquals(1, $taskCreation->create(array('title' => 'Test1', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test2', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $filter = new ProjectActivityTaskTitleFilter('#2'); $filter->withQuery($query)->apply(); diff --git a/tests/units/Filter/TaskAssigneeFilterTest.php b/tests/units/Filter/TaskAssigneeFilterTest.php index 356342c5..dec3824e 100644 --- a/tests/units/Filter/TaskAssigneeFilterTest.php +++ b/tests/units/Filter/TaskAssigneeFilterTest.php @@ -1,10 +1,10 @@ <?php use Kanboard\Filter\TaskAssigneeFilter; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\User; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\UserModel; require_once __DIR__.'/../Base.php'; @@ -12,9 +12,9 @@ class TaskAssigneeFilterTest extends Base { public function testWithIntegerAssigneeId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -37,9 +37,9 @@ class TaskAssigneeFilterTest extends Base public function testWithStringAssigneeId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -62,9 +62,9 @@ class TaskAssigneeFilterTest extends Base public function testWithUsername() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -87,10 +87,10 @@ class TaskAssigneeFilterTest extends Base public function testWithName() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar'))); @@ -114,9 +114,9 @@ class TaskAssigneeFilterTest extends Base public function testWithNobody() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -132,9 +132,9 @@ class TaskAssigneeFilterTest extends Base public function testWithCurrentUser() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); diff --git a/tests/units/Filter/TaskCommentFilterTest.php b/tests/units/Filter/TaskCommentFilterTest.php index 8d1b7f44..95ffb32f 100644 --- a/tests/units/Filter/TaskCommentFilterTest.php +++ b/tests/units/Filter/TaskCommentFilterTest.php @@ -1,10 +1,10 @@ <?php use Kanboard\Filter\TaskCommentFilter; -use Kanboard\Model\Comment; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\CommentModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; require_once __DIR__.'/../Base.php'; @@ -12,10 +12,10 @@ class TaskCommentFilterTest extends Base { public function testMatch() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $commentModel = new Comment($this->container); - $projectModel = new Project($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $commentModel = new CommentModel($this->container); + $projectModel = new ProjectModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); @@ -32,10 +32,10 @@ class TaskCommentFilterTest extends Base public function testNoMatch() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $commentModel = new Comment($this->container); - $projectModel = new Project($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $commentModel = new CommentModel($this->container); + $projectModel = new ProjectModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); diff --git a/tests/units/Filter/TaskCreatorFilterTest.php b/tests/units/Filter/TaskCreatorFilterTest.php index 1c344de7..b5abe6cf 100644 --- a/tests/units/Filter/TaskCreatorFilterTest.php +++ b/tests/units/Filter/TaskCreatorFilterTest.php @@ -1,10 +1,10 @@ <?php use Kanboard\Filter\TaskCreatorFilter; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\User; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\UserModel; require_once __DIR__.'/../Base.php'; @@ -12,9 +12,9 @@ class TaskCreatorFilterTest extends Base { public function testWithIntegerAssigneeId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -37,9 +37,9 @@ class TaskCreatorFilterTest extends Base public function testWithStringAssigneeId() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -62,9 +62,9 @@ class TaskCreatorFilterTest extends Base public function testWithUsername() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -87,10 +87,10 @@ class TaskCreatorFilterTest extends Base public function testWithName() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $query = $taskFinder->getExtendedQuery(); $this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar'))); @@ -114,9 +114,9 @@ class TaskCreatorFilterTest extends Base public function testWithNobody() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); @@ -132,9 +132,9 @@ class TaskCreatorFilterTest extends Base public function testWithCurrentUser() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); + $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'))); diff --git a/tests/units/Helper/AssetHelperTest.php b/tests/units/Helper/AssetHelperTest.php index 6ef5accd..da780c4b 100644 --- a/tests/units/Helper/AssetHelperTest.php +++ b/tests/units/Helper/AssetHelperTest.php @@ -3,14 +3,14 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Helper\AssetHelper; -use Kanboard\Model\Config; +use Kanboard\Model\ConfigModel; class AssetHelperTest extends Base { public function testCustomCss() { $h = new AssetHelper($this->container); - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertEmpty($h->customCss()); diff --git a/tests/units/Helper/ProjectActivityHelperTest.php b/tests/units/Helper/ProjectActivityHelperTest.php index 88b2d352..1ad95699 100644 --- a/tests/units/Helper/ProjectActivityHelperTest.php +++ b/tests/units/Helper/ProjectActivityHelperTest.php @@ -1,11 +1,11 @@ <?php use Kanboard\Helper\ProjectActivityHelper; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; require_once __DIR__.'/../Base.php'; @@ -13,10 +13,10 @@ class ProjectActivityHelperTest extends Base { public function testGetProjectEvents() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); @@ -24,9 +24,9 @@ class ProjectActivityHelperTest extends Base $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(3, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 3, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 3, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); $helper = new ProjectActivityHelper($this->container); $events = $helper->getProjectEvents(1); @@ -41,10 +41,10 @@ class ProjectActivityHelperTest extends Base public function testGetProjectsEvents() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'P2'))); @@ -54,9 +54,9 @@ class ProjectActivityHelperTest extends Base $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 2))); $this->assertEquals(3, $taskCreation->create(array('title' => 'Test', 'project_id' => 3))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); - $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(2, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(3, 3, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(3)))); $helper = new ProjectActivityHelper($this->container); $events = $helper->getProjectsEvents(array(1, 2)); @@ -71,18 +71,18 @@ class ProjectActivityHelperTest extends Base public function testGetTaskEvents() { - $taskFinder = new TaskFinder($this->container); - $taskCreation = new TaskCreation($this->container); - $projectModel = new Project($this->container); - $projectActivityModel = new ProjectActivity($this->container); + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectActivityModel = new ProjectActivityModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); - $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, Task::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 1, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(1)))); + $this->assertNotFalse($projectActivityModel->createEvent(1, 2, 1, TaskModel::EVENT_CREATE, array('task' => $taskFinder->getById(2)))); $helper = new ProjectActivityHelper($this->container); $events = $helper->getTaskEvents(1); diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php index 8f596541..c9447abb 100644 --- a/tests/units/Helper/TextHelperTest.php +++ b/tests/units/Helper/TextHelperTest.php @@ -3,16 +3,16 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Helper\TextHelper; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; class TextHelperTest extends Base { public function testMarkdownTaskLink() { $helper = new TextHelper($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertTrue($projectModel->enablePublicAccess(1)); diff --git a/tests/units/Helper/UrlHelperTest.php b/tests/units/Helper/UrlHelperTest.php index 34ab7604..b1f0a032 100644 --- a/tests/units/Helper/UrlHelperTest.php +++ b/tests/units/Helper/UrlHelperTest.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Helper\UrlHelper; -use Kanboard\Model\Config; +use Kanboard\Model\ConfigModel; use Kanboard\Core\Http\Request; class UrlHelperTest extends Base @@ -115,7 +115,7 @@ class UrlHelperTest extends Base $h = new UrlHelper($this->container); $this->assertEquals('http://kb:1234/', $h->base()); - $c = new Config($this->container); + $c = new ConfigModel($this->container); $c->save(array('application_url' => 'https://mykanboard/')); $this->container['memoryCache']->flush(); diff --git a/tests/units/Helper/UserHelperTest.php b/tests/units/Helper/UserHelperTest.php index be563b47..c149e663 100644 --- a/tests/units/Helper/UserHelperTest.php +++ b/tests/units/Helper/UserHelperTest.php @@ -4,13 +4,12 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Core\User\UserSession; use Kanboard\Helper\UserHelper; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\User as UserModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; use Kanboard\Core\Security\Role; -use Kanboard\Model\User; +use Kanboard\Model\UserModel; class UserHelperTest extends Base { @@ -76,7 +75,7 @@ class UserHelperTest extends Base public function testHasProjectAccessForAdmins() { $helper = new UserHelper($this->container); - $project = new Project($this->container); + $project = new ProjectModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -92,7 +91,7 @@ class UserHelperTest extends Base public function testHasProjectAccessForManagers() { $helper = new UserHelper($this->container); - $project = new Project($this->container); + $project = new ProjectModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -108,7 +107,7 @@ class UserHelperTest extends Base public function testHasProjectAccessForUsers() { $helper = new UserHelper($this->container); - $project = new Project($this->container); + $project = new ProjectModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -125,8 +124,8 @@ class UserHelperTest extends Base { $helper = new UserHelper($this->container); $user = new UserModel($this->container); - $project = new Project($this->container); - $projectUserRole = new ProjectUserRole($this->container); + $project = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -153,8 +152,8 @@ class UserHelperTest extends Base { $helper = new UserHelper($this->container); $user = new UserModel($this->container); - $project = new Project($this->container); - $projectUserRole = new ProjectUserRole($this->container); + $project = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -181,8 +180,8 @@ class UserHelperTest extends Base { $helper = new UserHelper($this->container); $user = new UserModel($this->container); - $project = new Project($this->container); - $projectUserRole = new ProjectUserRole($this->container); + $project = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -209,8 +208,8 @@ class UserHelperTest extends Base { $helper = new UserHelper($this->container); $user = new UserModel($this->container); - $project = new Project($this->container); - $projectUserRole = new ProjectUserRole($this->container); + $project = new ProjectModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); $this->container['sessionStorage']->user = array( 'id' => 2, @@ -235,11 +234,11 @@ class UserHelperTest extends Base public function testCanRemoveTask() { - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); $helper = new UserHelper($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $userSessionModel = new UserSession($this->container); $this->assertNotFalse($userModel->create(array('username' => 'toto', 'password' => '123456'))); @@ -278,7 +277,7 @@ class UserHelperTest extends Base $this->assertTrue($helper->canRemoveTask($task)); // User #2 can remove his own TaskViewController - $user = $userModel->getbyId(2); + $user = $userModel->getById(2); $this->assertNotEmpty($user); $userSessionModel->initialize($user); diff --git a/tests/units/Model/ActionTest.php b/tests/units/Model/ActionTest.php index ed687846..5db18983 100644 --- a/tests/units/Model/ActionTest.php +++ b/tests/units/Model/ActionTest.php @@ -2,27 +2,27 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Action; -use Kanboard\Model\Project; -use Kanboard\Model\Task; -use Kanboard\Model\User; -use Kanboard\Model\Column; -use Kanboard\Model\Category; -use Kanboard\Model\ProjectUserRole; +use Kanboard\Model\ActionModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\ProjectUserRoleModel; use Kanboard\Core\Security\Role; class ActionTest extends Base { public function testCreate() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); @@ -30,14 +30,14 @@ class ActionTest extends Base public function testRemove() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); @@ -49,14 +49,14 @@ class ActionTest extends Base public function testGetById() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); @@ -65,28 +65,28 @@ class ActionTest extends Base $this->assertNotEmpty($action); $this->assertEquals(1, $action['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $action['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $action['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $action['event_name']); $this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $action['params']); } public function testGetAll() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 2, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 6, 'color_id' => 'blue'), ))); @@ -96,33 +96,33 @@ class ActionTest extends Base $this->assertEquals(1, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']); $this->assertEquals(2, $actions[1]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[1]['action_name']); - $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[1]['event_name']); + $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[1]['event_name']); $this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[1]['params']); } public function testGetAllByProject() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 2, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 6, 'color_id' => 'blue'), ))); @@ -132,7 +132,7 @@ class ActionTest extends Base $this->assertEquals(1, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']); @@ -141,16 +141,16 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[0]['params']); } public function testGetAllByUser() { - $projectModel = new Project($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -165,21 +165,21 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 2, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 6, 'color_id' => 'blue'), ))); $this->assertEquals(3, $actionModel->create(array( 'project_id' => 3, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 10, 'color_id' => 'green'), ))); @@ -192,7 +192,7 @@ class ActionTest extends Base $this->assertEquals(1, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']); $actions = $actionModel->getAllByUser(3); @@ -200,21 +200,21 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[0]['params']); } public function testDuplicateWithColumnAndColorParameter() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); @@ -226,21 +226,21 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 5, 'color_id' => 'red'), $actions[0]['params']); } public function testDuplicateWithColumnsParameter() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('src_column_id' => 1, 'dst_column_id' => 2, 'dest_column_id' => 3), ))); @@ -252,15 +252,15 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('src_column_id' => 5, 'dst_column_id' => 6, 'dest_column_id' => 7), $actions[0]['params']); } public function testDuplicateWithColumnParameterNotfound() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -269,14 +269,14 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE, + 'event_name' => TaskModel::EVENT_CREATE, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'), ))); $this->assertEquals(2, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignColorColumn', 'params' => array('column_id' => 2, 'color_id' => 'green'), ))); @@ -288,14 +288,14 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 5, 'color_id' => 'red'), $actions[0]['params']); } public function testDuplicateWithProjectParameter() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -303,7 +303,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CLOSE, + 'event_name' => TaskModel::EVENT_CLOSE, 'action_name' => '\Kanboard\Action\TaskDuplicateAnotherProject', 'params' => array('column_id' => 1, 'project_id' => 3), ))); @@ -315,21 +315,21 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskDuplicateAnotherProject', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CLOSE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CLOSE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 5, 'project_id' => 3), $actions[0]['params']); } public function testDuplicateWithProjectParameterIdenticalToDestination() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CLOSE, + 'event_name' => TaskModel::EVENT_CLOSE, 'action_name' => '\Kanboard\Action\TaskDuplicateAnotherProject', 'params' => array('column_id' => 1, 'project_id' => 2), ))); @@ -342,10 +342,10 @@ class ActionTest extends Base public function testDuplicateWithUserParameter() { - $projectUserRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -357,7 +357,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2), ))); @@ -369,16 +369,16 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignSpecificUser', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 5, 'user_id' => 2), $actions[0]['params']); } public function testDuplicateWithUserParameterButNotAssignable() { - $projectUserRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -390,7 +390,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2), ))); @@ -403,10 +403,10 @@ class ActionTest extends Base public function testDuplicateWithUserParameterButNotAvailable() { - $projectUserRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -417,7 +417,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => '\Kanboard\Action\TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'owner_id' => 2), ))); @@ -430,9 +430,9 @@ class ActionTest extends Base public function testDuplicateWithCategoryParameter() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -442,7 +442,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE_UPDATE, + 'event_name' => TaskModel::EVENT_CREATE_UPDATE, 'action_name' => '\Kanboard\Action\TaskAssignColorCategory', 'params' => array('column_id' => 1, 'category_id' => 1), ))); @@ -454,15 +454,15 @@ class ActionTest extends Base $this->assertEquals(2, $actions[0]['project_id']); $this->assertEquals('\Kanboard\Action\TaskAssignColorCategory', $actions[0]['action_name']); - $this->assertEquals(Task::EVENT_CREATE_UPDATE, $actions[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CREATE_UPDATE, $actions[0]['event_name']); $this->assertEquals(array('column_id' => 5, 'category_id' => 2), $actions[0]['params']); } public function testDuplicateWithCategoryParameterButDifferentName() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -472,7 +472,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE_UPDATE, + 'event_name' => TaskModel::EVENT_CREATE_UPDATE, 'action_name' => '\Kanboard\Action\TaskAssignColorCategory', 'params' => array('column_id' => 1, 'category_id' => 1), ))); @@ -485,9 +485,9 @@ class ActionTest extends Base public function testDuplicateWithCategoryParameterButNotFound() { - $projectModel = new Project($this->container); - $actionModel = new Action($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); @@ -496,7 +496,7 @@ class ActionTest extends Base $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE_UPDATE, + 'event_name' => TaskModel::EVENT_CREATE_UPDATE, 'action_name' => '\Kanboard\Action\TaskAssignColorCategory', 'params' => array('column_id' => 1, 'category_id' => 1), ))); diff --git a/tests/units/Model/BoardTest.php b/tests/units/Model/BoardTest.php index 20665ac2..80587d89 100644 --- a/tests/units/Model/BoardTest.php +++ b/tests/units/Model/BoardTest.php @@ -2,21 +2,21 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\Board; -use Kanboard\Model\Column; -use Kanboard\Model\Config; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Swimlane; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\BoardModel; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\SwimlaneModel; class BoardTest extends Base { public function testCreation() { - $p = new Project($this->container); - $columnModel = new Column($this->container); - $c = new Config($this->container); + $p = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); + $c = new ConfigModel($this->container); // Default columns @@ -48,8 +48,8 @@ class BoardTest extends Base public function testGetBoard() { - $p = new Project($this->container); - $b = new Board($this->container); + $p = new ProjectModel($this->container); + $b = new BoardModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); @@ -69,11 +69,11 @@ class BoardTest extends Base public function testGetBoardWithSwimlane() { - $b = new Board($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $b = new BoardModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); diff --git a/tests/units/Model/CategoryTest.php b/tests/units/Model/CategoryTest.php index 600007d0..1fdc51f6 100644 --- a/tests/units/Model/CategoryTest.php +++ b/tests/units/Model/CategoryTest.php @@ -2,20 +2,20 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Config; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Category; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\CategoryModel; class CategoryTest extends Base { public function testCreation() { - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); @@ -33,8 +33,8 @@ class CategoryTest extends Base public function testExists() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); @@ -44,8 +44,8 @@ class CategoryTest extends Base public function testGetById() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); @@ -59,8 +59,8 @@ class CategoryTest extends Base public function testGetNameById() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); @@ -71,8 +71,8 @@ class CategoryTest extends Base public function testGetIdByName() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); @@ -83,8 +83,8 @@ class CategoryTest extends Base public function testGetList() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); @@ -117,8 +117,8 @@ class CategoryTest extends Base public function testGetAll() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); @@ -140,9 +140,9 @@ class CategoryTest extends Base public function testCreateDefaultCategories() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); - $configModel = new Config($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); + $configModel = new ConfigModel($this->container); $this->assertTrue($configModel->save(array('project_categories' => 'C1, C2, C3'))); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); @@ -157,8 +157,8 @@ class CategoryTest extends Base public function testUpdate() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); @@ -172,10 +172,10 @@ class CategoryTest extends Base public function testRemove() { - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); @@ -195,8 +195,8 @@ class CategoryTest extends Base public function testDuplicate() { - $projectModel = new Project($this->container); - $categoryModel = new Category($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); diff --git a/tests/units/Model/ColorTest.php b/tests/units/Model/ColorTest.php index e96ecb6b..2a2c4b87 100644 --- a/tests/units/Model/ColorTest.php +++ b/tests/units/Model/ColorTest.php @@ -2,14 +2,14 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Color; -use Kanboard\Model\Config; +use Kanboard\Model\ColorModel; +use Kanboard\Model\ConfigModel; class ColorTest extends Base { public function testFind() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $this->assertEquals('yellow', $colorModel->find('yellow')); $this->assertEquals('yellow', $colorModel->find('Yellow')); $this->assertEquals('dark_grey', $colorModel->find('Dark Grey')); @@ -18,7 +18,7 @@ class ColorTest extends Base public function testGetColorProperties() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $expected = array( 'name' => 'Light Green', 'background' => '#dcedc8', @@ -38,7 +38,7 @@ class ColorTest extends Base public function testGetList() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $colors = $colorModel->getList(); $this->assertCount(16, $colors); @@ -52,8 +52,8 @@ class ColorTest extends Base public function testGetDefaultColor() { - $colorModel = new Color($this->container); - $configModel = new Config($this->container); + $colorModel = new ColorModel($this->container); + $configModel = new ConfigModel($this->container); $this->assertEquals('yellow', $colorModel->getDefaultColor()); @@ -64,7 +64,7 @@ class ColorTest extends Base public function testGetDefaultColors() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $colors = $colorModel->getDefaultColors(); $this->assertCount(16, $colors); @@ -72,19 +72,19 @@ class ColorTest extends Base public function testGetBorderColor() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $this->assertEquals('rgb(74, 227, 113)', $colorModel->getBorderColor('green')); } public function testGetBackgroundColor() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $this->assertEquals('rgb(189, 244, 203)', $colorModel->getBackgroundColor('green')); } public function testGetCss() { - $colorModel = new Color($this->container); + $colorModel = new ColorModel($this->container); $css = $colorModel->getCss(); $this->assertStringStartsWith('div.color-yellow {', $css); diff --git a/tests/units/Model/ColumnTest.php b/tests/units/Model/ColumnTest.php index e40f89c6..7340a274 100644 --- a/tests/units/Model/ColumnTest.php +++ b/tests/units/Model/ColumnTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\Column; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ColumnModel; class ColumnTest extends Base { public function testGetColumn() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -24,8 +24,8 @@ class ColumnTest extends Base public function testGetFirstColumnId() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $columnModel->getFirstColumnId(1)); @@ -33,8 +33,8 @@ class ColumnTest extends Base public function testGetLastColumnId() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals(4, $columnModel->getLastColumnId(1)); @@ -42,8 +42,8 @@ class ColumnTest extends Base public function testGetLastColumnPosition() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals(4, $columnModel->getLastColumnPosition(1)); @@ -51,8 +51,8 @@ class ColumnTest extends Base public function testGetColumnIdByTitle() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals(2, $columnModel->getColumnIdByTitle(1, 'Ready')); @@ -60,8 +60,8 @@ class ColumnTest extends Base public function testGetTitleByColumnId() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals('Work in progress', $columnModel->getColumnTitleById(3)); @@ -69,8 +69,8 @@ class ColumnTest extends Base public function testGetAll() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -96,8 +96,8 @@ class ColumnTest extends Base public function testGetList() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -119,8 +119,8 @@ class ColumnTest extends Base public function testAddColumn() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertNotFalse($columnModel->create(1, 'another column')); @@ -142,8 +142,8 @@ class ColumnTest extends Base public function testUpdateColumn() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -163,8 +163,8 @@ class ColumnTest extends Base public function testRemoveColumn() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertTrue($columnModel->remove(3)); @@ -177,8 +177,8 @@ class ColumnTest extends Base public function testChangePosition() { - $projectModel = new Project($this->container); - $columnModel = new Column($this->container); + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); diff --git a/tests/units/Model/CommentTest.php b/tests/units/Model/CommentTest.php index bb96e4f4..7250ae0b 100644 --- a/tests/units/Model/CommentTest.php +++ b/tests/units/Model/CommentTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\Comment; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\CommentModel; class CommentTest extends Base { public function testCreate() { - $c = new Comment($this->container); - $tc = new TaskCreation($this->container); - $p = new Project($this->container); + $c = new CommentModel($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); @@ -38,9 +38,9 @@ class CommentTest extends Base public function testGetAll() { - $c = new Comment($this->container); - $tc = new TaskCreation($this->container); - $p = new Project($this->container); + $c = new CommentModel($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); @@ -61,9 +61,9 @@ class CommentTest extends Base public function testUpdate() { - $c = new Comment($this->container); - $tc = new TaskCreation($this->container); - $p = new Project($this->container); + $c = new CommentModel($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); @@ -77,9 +77,9 @@ class CommentTest extends Base public function validateRemove() { - $c = new Comment($this->container); - $tc = new TaskCreation($this->container); - $p = new Project($this->container); + $c = new CommentModel($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); diff --git a/tests/units/Model/ConfigTest.php b/tests/units/Model/ConfigTest.php index ad74ad50..3345ee3e 100644 --- a/tests/units/Model/ConfigTest.php +++ b/tests/units/Model/ConfigTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Config; +use Kanboard\Model\ConfigModel; class ConfigTest extends Base { public function testRegenerateToken() { - $configModel = new Config($this->container); + $configModel = new ConfigModel($this->container); $token = $configModel->getOption('api_token'); $this->assertTrue($configModel->regenerateToken('api_token')); $this->assertNotEquals($token, $configModel->getOption('api_token')); @@ -16,7 +16,7 @@ class ConfigTest extends Base public function testCRUDOperations() { - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertTrue($c->save(array('key1' => 'value1'))); $this->assertTrue($c->save(array('key1' => 'value2'))); @@ -41,7 +41,7 @@ class ConfigTest extends Base public function testSaveApplicationUrl() { - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertTrue($c->save(array('application_url' => 'http://localhost/'))); $this->assertEquals('http://localhost/', $c->getOption('application_url')); @@ -55,7 +55,7 @@ class ConfigTest extends Base public function testDefaultValues() { - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertEquals(172800, $c->getOption('board_highlight_period')); $this->assertEquals(60, $c->getOption('board_public_refresh_interval')); @@ -92,7 +92,7 @@ class ConfigTest extends Base public function testGetOption() { - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertEquals('', $c->getOption('board_columns')); $this->assertEquals('test', $c->getOption('board_columns', 'test')); @@ -101,7 +101,7 @@ class ConfigTest extends Base public function testGetWithCaching() { - $c = new Config($this->container); + $c = new ConfigModel($this->container); $this->assertEquals('UTC', $c->get('application_timezone')); $this->assertTrue($c->save(array('application_timezone' => 'Europe/Paris'))); diff --git a/tests/units/Model/CurrencyTest.php b/tests/units/Model/CurrencyTest.php index 0bc71da6..162cdfc1 100644 --- a/tests/units/Model/CurrencyTest.php +++ b/tests/units/Model/CurrencyTest.php @@ -2,20 +2,20 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Currency; +use Kanboard\Model\CurrencyModel; class CurrencyTest extends Base { public function testGetCurrencies() { - $currencyModel = new Currency($this->container); + $currencyModel = new CurrencyModel($this->container); $currencies = $currencyModel->getCurrencies(); $this->assertArrayHasKey('EUR', $currencies); } public function testGetAll() { - $currencyModel = new Currency($this->container); + $currencyModel = new CurrencyModel($this->container); $currencies = $currencyModel->getAll(); $this->assertCount(0, $currencies); @@ -28,21 +28,21 @@ class CurrencyTest extends Base public function testCreate() { - $currencyModel = new Currency($this->container); + $currencyModel = new CurrencyModel($this->container); $this->assertNotFalse($currencyModel->create('EUR', 1.2)); $this->assertNotFalse($currencyModel->create('EUR', 1.5)); } public function testUpdate() { - $currencyModel = new Currency($this->container); + $currencyModel = new CurrencyModel($this->container); $this->assertNotFalse($currencyModel->create('EUR', 1.1)); $this->assertNotFalse($currencyModel->update('EUR', 2.2)); } public function testGetPrice() { - $currencyModel = new Currency($this->container); + $currencyModel = new CurrencyModel($this->container); $this->assertEquals(123, $currencyModel->getPrice('USD', 123)); diff --git a/tests/units/Model/CustomFilterTest.php b/tests/units/Model/CustomFilterTest.php index a73bc401..463a1c91 100644 --- a/tests/units/Model/CustomFilterTest.php +++ b/tests/units/Model/CustomFilterTest.php @@ -2,16 +2,16 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\CustomFilter; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\CustomFilterModel; class CustomFilterTest extends Base { public function testCreation() { - $p = new Project($this->container); - $cf = new CustomFilter($this->container); + $p = new ProjectModel($this->container); + $cf = new CustomFilterModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'status:open color:blue', 'project_id' => 1, 'user_id' => 1))); @@ -36,8 +36,8 @@ class CustomFilterTest extends Base public function testModification() { - $p = new Project($this->container); - $cf = new CustomFilter($this->container); + $p = new ProjectModel($this->container); + $cf = new CustomFilterModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'status:open color:blue', 'project_id' => 1, 'user_id' => 1))); @@ -54,9 +54,9 @@ class CustomFilterTest extends Base public function testGetAll() { - $u = new User($this->container); - $p = new Project($this->container); - $cf = new CustomFilter($this->container); + $u = new UserModel($this->container); + $p = new ProjectModel($this->container); + $cf = new CustomFilterModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest 1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest 2'))); @@ -128,8 +128,8 @@ class CustomFilterTest extends Base public function testRemove() { - $p = new Project($this->container); - $cf = new CustomFilter($this->container); + $p = new ProjectModel($this->container); + $cf = new CustomFilterModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'status:open color:blue', 'project_id' => 1, 'user_id' => 1))); diff --git a/tests/units/Model/GroupMemberTest.php b/tests/units/Model/GroupMemberTest.php index 0ff9fdf6..edc9d98c 100644 --- a/tests/units/Model/GroupMemberTest.php +++ b/tests/units/Model/GroupMemberTest.php @@ -2,16 +2,16 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Group; -use Kanboard\Model\User; -use Kanboard\Model\GroupMember; +use Kanboard\Model\GroupModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupMemberModel; class GroupMemberTest extends Base { public function testAddRemove() { - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); $this->assertEquals(1, $groupModel->create('Test')); @@ -32,9 +32,9 @@ class GroupMemberTest extends Base public function testMembers() { - $userModel = new User($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); + $userModel = new UserModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); $this->assertEquals(1, $groupModel->create('Group A')); $this->assertEquals(2, $groupModel->create('Group B')); diff --git a/tests/units/Model/GroupTest.php b/tests/units/Model/GroupTest.php index 36b47dc5..85c2c5d9 100644 --- a/tests/units/Model/GroupTest.php +++ b/tests/units/Model/GroupTest.php @@ -2,20 +2,20 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Group; +use Kanboard\Model\GroupModel; class GroupTest extends Base { public function testCreation() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $this->assertEquals(1, $groupModel->create('Test')); $this->assertFalse($groupModel->create('Test')); } public function testGetById() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $this->assertEquals(1, $groupModel->create('Test')); $group = $groupModel->getById(1); @@ -27,7 +27,7 @@ class GroupTest extends Base public function testGetAll() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $this->assertEquals(1, $groupModel->create('B')); $this->assertEquals(2, $groupModel->create('A', 'uuid')); @@ -41,7 +41,7 @@ class GroupTest extends Base public function testUpdate() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $this->assertEquals(1, $groupModel->create('Test')); $this->assertTrue($groupModel->update(array('id' => 1, 'name' => 'My group', 'external_id' => 'test'))); @@ -52,7 +52,7 @@ class GroupTest extends Base public function testRemove() { - $groupModel = new Group($this->container); + $groupModel = new GroupModel($this->container); $this->assertEquals(1, $groupModel->create('Test')); $this->assertTrue($groupModel->remove(1)); $this->assertEmpty($groupModel->getById(1)); diff --git a/tests/units/Model/LanguageTest.php b/tests/units/Model/LanguageTest.php index dff98a83..4330c3c8 100644 --- a/tests/units/Model/LanguageTest.php +++ b/tests/units/Model/LanguageTest.php @@ -1,6 +1,6 @@ <?php -use Kanboard\Model\Language; +use Kanboard\Model\LanguageModel; require_once __DIR__.'/../Base.php'; @@ -8,21 +8,21 @@ class LanguageTest extends Base { public function testGetCodes() { - $codes = Language::getCodes(); + $codes = LanguageModel::getCodes(); $this->assertContains('fr_FR', $codes); $this->assertContains('en_US', $codes); } public function testFindCode() { - $this->assertSame('', Language::findCode('xx-XX')); - $this->assertSame('fr_FR', Language::findCode('fr-FR')); - $this->assertSame('en_US', Language::findCode('en-US')); + $this->assertSame('', LanguageModel::findCode('xx-XX')); + $this->assertSame('fr_FR', LanguageModel::findCode('fr-FR')); + $this->assertSame('en_US', LanguageModel::findCode('en-US')); } public function testGetJsLanguage() { - $languageModel = new Language($this->container); + $languageModel = new LanguageModel($this->container); $this->assertEquals('en', $languageModel->getJsLanguageCode()); $this->container['sessionStorage']->user = array('language' => 'fr_FR'); @@ -34,7 +34,7 @@ class LanguageTest extends Base public function testGetCurrentLanguage() { - $languageModel = new Language($this->container); + $languageModel = new LanguageModel($this->container); $this->assertEquals('en_US', $languageModel->getCurrentLanguage()); $this->container['sessionStorage']->user = array('language' => 'fr_FR'); @@ -46,7 +46,7 @@ class LanguageTest extends Base public function testGetLanguages() { - $languageModel = new Language($this->container); + $languageModel = new LanguageModel($this->container); $this->assertNotEmpty($languageModel->getLanguages()); $this->assertArrayHasKey('fr_FR', $languageModel->getLanguages()); $this->assertContains('Français', $languageModel->getLanguages()); diff --git a/tests/units/Model/LastLoginTest.php b/tests/units/Model/LastLoginTest.php index fc5ea1e5..8c291e15 100644 --- a/tests/units/Model/LastLoginTest.php +++ b/tests/units/Model/LastLoginTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\LastLogin; +use Kanboard\Model\LastLoginModel; class LastLoginTest extends Base { public function testCreate() { - $lastLoginModel = new LastLogin($this->container); + $lastLoginModel = new LastLoginModel($this->container); $this->assertTrue($lastLoginModel->create('Test1', 1, '127.0.0.1', 'My browser')); $this->assertTrue($lastLoginModel->create('Test2', 1, '127.0.0.1', str_repeat('Too long', 50))); @@ -29,7 +29,7 @@ class LastLoginTest extends Base public function testCleanup() { - $lastLoginModel = new LastLogin($this->container); + $lastLoginModel = new LastLoginModel($this->container); for ($i = 0; $i < $lastLoginModel::NB_LOGINS + 5; $i++) { $this->assertTrue($lastLoginModel->create('Test' . $i, 1, '127.0.0.1', 'My browser')); diff --git a/tests/units/Model/LinkTest.php b/tests/units/Model/LinkTest.php index b102646d..600c09f3 100644 --- a/tests/units/Model/LinkTest.php +++ b/tests/units/Model/LinkTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Link; +use Kanboard\Model\LinkModel; class LinkTest extends Base { public function testCreateLink() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $this->assertNotFalse($l->create('Link A')); $this->assertFalse($l->create('Link A')); @@ -38,7 +38,7 @@ class LinkTest extends Base public function testGetOppositeLinkId() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $this->assertNotFalse($l->create('Link A')); $this->assertNotFalse($l->create('Link B', 'Link C')); @@ -50,7 +50,7 @@ class LinkTest extends Base public function testUpdate() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $this->assertTrue($l->update(array('id' => 2, 'label' => 'test', 'opposite_id' => 0))); @@ -62,7 +62,7 @@ class LinkTest extends Base public function testRemove() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $link = $l->getById(3); $this->assertNotEmpty($link); @@ -82,7 +82,7 @@ class LinkTest extends Base public function testGetMergedList() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $links = $l->getMergedList(); $this->assertNotEmpty($links); @@ -93,7 +93,7 @@ class LinkTest extends Base public function testGetList() { - $l = new Link($this->container); + $l = new LinkModel($this->container); $links = $l->getList(); $this->assertNotEmpty($links); diff --git a/tests/units/Model/NotificationTest.php b/tests/units/Model/NotificationTest.php index d5ec7735..96ee5f4e 100644 --- a/tests/units/Model/NotificationTest.php +++ b/tests/units/Model/NotificationTest.php @@ -2,27 +2,27 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Subtask; -use Kanboard\Model\Comment; -use Kanboard\Model\TaskFile; -use Kanboard\Model\Task; -use Kanboard\Model\Project; -use Kanboard\Model\Notification; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\CommentModel; +use Kanboard\Model\TaskFileModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\NotificationModel; use Kanboard\Subscriber\NotificationSubscriber; class NotificationTest extends Base { public function testGetTitle() { - $wn = new Notification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $c = new Comment($this->container); - $f = new TaskFile($this->container); + $wn = new NotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $c = new CommentModel($this->container); + $f = new TaskFileModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -62,7 +62,7 @@ class NotificationTest extends Base $this->assertNotEmpty($title); } - $this->assertNotEmpty($wn->getTitleWithoutAuthor(Task::EVENT_OVERDUE, array('tasks' => array(array('id' => 1))))); + $this->assertNotEmpty($wn->getTitleWithoutAuthor(TaskModel::EVENT_OVERDUE, array('tasks' => array(array('id' => 1))))); $this->assertNotEmpty($wn->getTitleWithoutAuthor('unkown', array())); } } diff --git a/tests/units/Model/PasswordResetTest.php b/tests/units/Model/PasswordResetTest.php index f88d24fb..01ca1d12 100644 --- a/tests/units/Model/PasswordResetTest.php +++ b/tests/units/Model/PasswordResetTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\User; -use Kanboard\Model\PasswordReset; +use Kanboard\Model\UserModel; +use Kanboard\Model\PasswordResetModel; class PasswordResetTest extends Base { public function testCreate() { - $userModel = new User($this->container); - $passwordResetModel = new PasswordReset($this->container); + $userModel = new UserModel($this->container); + $passwordResetModel = new PasswordResetModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'email' => 'user1@localhost'))); @@ -22,8 +22,8 @@ class PasswordResetTest extends Base public function testGetUserIdByToken() { - $userModel = new User($this->container); - $passwordResetModel = new PasswordReset($this->container); + $userModel = new UserModel($this->container); + $passwordResetModel = new PasswordResetModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user2', 'email' => 'user1@localhost'))); @@ -33,8 +33,8 @@ class PasswordResetTest extends Base public function testGetUserIdByTokenWhenExpired() { - $userModel = new User($this->container); - $passwordResetModel = new PasswordReset($this->container); + $userModel = new UserModel($this->container); + $passwordResetModel = new PasswordResetModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user2', 'email' => 'user1@localhost'))); @@ -44,8 +44,8 @@ class PasswordResetTest extends Base public function testDisableTokens() { - $userModel = new User($this->container); - $passwordResetModel = new PasswordReset($this->container); + $userModel = new UserModel($this->container); + $passwordResetModel = new PasswordResetModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user2', 'email' => 'user1@localhost'))); @@ -63,8 +63,8 @@ class PasswordResetTest extends Base public function testGetAll() { - $userModel = new User($this->container); - $passwordResetModel = new PasswordReset($this->container); + $userModel = new UserModel($this->container); + $passwordResetModel = new PasswordResetModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user2', 'email' => 'user1@localhost'))); $this->assertNotFalse($passwordResetModel->create('user2')); diff --git a/tests/units/Model/ProjectActivityTest.php b/tests/units/Model/ProjectActivityTest.php index 16036cd4..0b87b515 100644 --- a/tests/units/Model/ProjectActivityTest.php +++ b/tests/units/Model/ProjectActivityTest.php @@ -2,43 +2,43 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Task; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\ProjectActivity; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectActivityModel; +use Kanboard\Model\ProjectModel; class ProjectActivityTest extends Base { public function testCreation() { - $projectActivity = new ProjectActivity($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); - $projectModel = new Project($this->container); + $projectActivity = new ProjectActivityModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Task #1', 'project_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Task #2', 'project_id' => 1))); - $this->assertTrue($projectActivity->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $taskFinder->getById(1)))); - $this->assertTrue($projectActivity->createEvent(1, 2, 1, Task::EVENT_UPDATE, array('task' => $taskFinder->getById(2)))); - $this->assertFalse($projectActivity->createEvent(1, 1, 0, Task::EVENT_OPEN, array('task' => $taskFinder->getById(1)))); + $this->assertTrue($projectActivity->createEvent(1, 1, 1, TaskModel::EVENT_CLOSE, array('task' => $taskFinder->getById(1)))); + $this->assertTrue($projectActivity->createEvent(1, 2, 1, TaskModel::EVENT_UPDATE, array('task' => $taskFinder->getById(2)))); + $this->assertFalse($projectActivity->createEvent(1, 1, 0, TaskModel::EVENT_OPEN, array('task' => $taskFinder->getById(1)))); $events = $projectActivity->getQuery()->desc('id')->findAll(); $this->assertCount(2, $events); $this->assertEquals(time(), $events[0]['date_creation'], '', 1); - $this->assertEquals(Task::EVENT_UPDATE, $events[0]['event_name']); - $this->assertEquals(Task::EVENT_CLOSE, $events[1]['event_name']); + $this->assertEquals(TaskModel::EVENT_UPDATE, $events[0]['event_name']); + $this->assertEquals(TaskModel::EVENT_CLOSE, $events[1]['event_name']); } public function testCleanup() { - $projectActivity = new ProjectActivity($this->container); - $taskCreation = new TaskCreation($this->container); - $taskFinder = new TaskFinder($this->container); - $projectModel = new Project($this->container); + $projectActivity = new ProjectActivityModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $taskFinder = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Task #1', 'project_id' => 1))); @@ -48,7 +48,7 @@ class ProjectActivityTest extends Base $task = $taskFinder->getById(1); for ($i = 0; $i < $nb_events; $i++) { - $this->assertTrue($projectActivity->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $task))); + $this->assertTrue($projectActivity->createEvent(1, 1, 1, TaskModel::EVENT_CLOSE, array('task' => $task))); } $this->assertEquals($nb_events, $this->container['db']->table('project_activities')->count()); diff --git a/tests/units/Model/ProjectDailyColumnStatsTest.php b/tests/units/Model/ProjectDailyColumnStatsTest.php index 4f92ad2b..5e500340 100644 --- a/tests/units/Model/ProjectDailyColumnStatsTest.php +++ b/tests/units/Model/ProjectDailyColumnStatsTest.php @@ -2,29 +2,29 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectDailyColumnStats; -use Kanboard\Model\Config; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectDailyColumnStatsModel; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; class ProjectDailyColumnStatsTest extends Base { public function testUpdateTotalsWithScoreAtNull() { - $projectModel = new Project($this->container); - $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $projectDailyColumnStats = new ProjectDailyColumnStatsModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); $projectDailyColumnStats->updateTotals(1, '2016-01-16'); - $task = $this->container['db']->table(Task::TABLE)->findOne(); + $task = $this->container['db']->table(TaskModel::TABLE)->findOne(); $this->assertNull($task['score']); - $stats = $this->container['db']->table(ProjectDailyColumnStats::TABLE) + $stats = $this->container['db']->table(ProjectDailyColumnStatsModel::TABLE) ->asc('day') ->asc('column_id') ->columns('day', 'project_id', 'column_id', 'total', 'score') @@ -45,8 +45,8 @@ class ProjectDailyColumnStatsTest extends Base public function testUpdateTotals() { - $projectModel = new Project($this->container); - $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); + $projectModel = new ProjectModel($this->container); + $projectDailyColumnStats = new ProjectDailyColumnStatsModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->createTasks(1, 2, 1); @@ -68,7 +68,7 @@ class ProjectDailyColumnStatsTest extends Base $projectDailyColumnStats->updateTotals(1, '2016-01-17'); - $stats = $this->container['db']->table(ProjectDailyColumnStats::TABLE) + $stats = $this->container['db']->table(ProjectDailyColumnStatsModel::TABLE) ->asc('day') ->asc('column_id') ->columns('day', 'project_id', 'column_id', 'total', 'score') @@ -117,9 +117,9 @@ class ProjectDailyColumnStatsTest extends Base public function testUpdateTotalsWithOnlyOpenTasks() { - $configModel = new Config($this->container); - $projectModel = new Project($this->container); - $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); + $configModel = new ConfigModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectDailyColumnStats = new ProjectDailyColumnStatsModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertTrue($configModel->save(array('cfd_include_closed_tasks' => 0))); @@ -144,7 +144,7 @@ class ProjectDailyColumnStatsTest extends Base $projectDailyColumnStats->updateTotals(1, '2016-01-17'); - $stats = $this->container['db']->table(ProjectDailyColumnStats::TABLE) + $stats = $this->container['db']->table(ProjectDailyColumnStatsModel::TABLE) ->asc('day') ->asc('column_id') ->columns('day', 'project_id', 'column_id', 'total', 'score') @@ -193,8 +193,8 @@ class ProjectDailyColumnStatsTest extends Base public function testCountDays() { - $projectModel = new Project($this->container); - $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); + $projectModel = new ProjectModel($this->container); + $projectDailyColumnStats = new ProjectDailyColumnStatsModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -208,8 +208,8 @@ class ProjectDailyColumnStatsTest extends Base public function testGetAggregatedMetrics() { - $projectModel = new Project($this->container); - $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); + $projectModel = new ProjectModel($this->container); + $projectDailyColumnStats = new ProjectDailyColumnStatsModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->createTasks(1, 2, 1); @@ -258,7 +258,7 @@ class ProjectDailyColumnStatsTest extends Base private function createTasks($column_id, $score, $is_active) { - $taskCreationModel = new TaskCreation($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => $column_id, 'score' => $score, 'is_active' => $is_active))); } } diff --git a/tests/units/Model/ProjectDailyStatsTest.php b/tests/units/Model/ProjectDailyStatsTest.php index c3b20cb9..851af985 100644 --- a/tests/units/Model/ProjectDailyStatsTest.php +++ b/tests/units/Model/ProjectDailyStatsTest.php @@ -2,19 +2,19 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectDailyStats; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskStatus; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectDailyStatsModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskStatusModel; class ProjectDailyStatsTest extends Base { public function testUpdateTotals() { - $p = new Project($this->container); - $pds = new ProjectDailyStats($this->container); - $tc = new TaskCreation($this->container); - $ts = new TaskStatus($this->container); + $p = new ProjectModel($this->container); + $pds = new ProjectDailyStatsModel($this->container); + $tc = new TaskCreationModel($this->container); + $ts = new TaskStatusModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest'))); diff --git a/tests/units/Model/ProjectDuplicationTest.php b/tests/units/Model/ProjectDuplicationTest.php index 4023a28f..312c7168 100644 --- a/tests/units/Model/ProjectDuplicationTest.php +++ b/tests/units/Model/ProjectDuplicationTest.php @@ -2,33 +2,33 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Action; -use Kanboard\Model\Project; -use Kanboard\Model\Category; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\ProjectGroupRole; -use Kanboard\Model\ProjectDuplication; -use Kanboard\Model\User; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; -use Kanboard\Model\Swimlane; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\ActionModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\ProjectGroupRoleModel; +use Kanboard\Model\ProjectDuplicationModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; +use Kanboard\Model\SwimlaneModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; use Kanboard\Core\Security\Role; class ProjectDuplicationTest extends Base { public function testGetSelections() { - $projectDuplicationModel = new ProjectDuplication($this->container); + $projectDuplicationModel = new ProjectDuplicationModel($this->container); $this->assertCount(6, $projectDuplicationModel->getOptionalSelection()); $this->assertCount(7, $projectDuplicationModel->getPossibleSelection()); } public function testGetClonedProjectName() { - $pd = new ProjectDuplication($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals('test (Clone)', $pd->getClonedProjectName('test')); @@ -41,8 +41,8 @@ class ProjectDuplicationTest extends Base public function testClonePublicProject() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Public'))); $this->assertEquals(2, $pd->duplicate(1)); @@ -59,9 +59,9 @@ class ProjectDuplicationTest extends Base public function testClonePrivateProject() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $pp = new ProjectUserRole($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $pp = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Private', 'is_private' => 1), 1, true)); $this->assertEquals(2, $pd->duplicate(1)); @@ -80,8 +80,8 @@ class ProjectDuplicationTest extends Base public function testCloneSharedProject() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Shared'))); $this->assertTrue($p->update(array('id' => 1, 'is_public' => 1, 'token' => 'test'))); @@ -101,8 +101,8 @@ class ProjectDuplicationTest extends Base public function testCloneInactiveProject() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Inactive'))); $this->assertTrue($p->update(array('id' => 1, 'is_active' => 0))); @@ -120,16 +120,16 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithOwner() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Owner'))); $project = $p->getById(1); $this->assertEquals(0, $project['owner_id']); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 1)); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel'), 1)); $project = $p->getById(2); $this->assertNotEmpty($project); @@ -141,15 +141,15 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithDifferentName() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Owner'))); $project = $p->getById(1); $this->assertEquals(0, $project['owner_id']); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 1, 'Foobar')); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel'), 1, 'Foobar')); $project = $p->getById(2); $this->assertNotEmpty($project); @@ -159,8 +159,8 @@ class ProjectDuplicationTest extends Base public function testCloneProjectAndForceItToBePrivate() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Owner'))); @@ -168,7 +168,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(0, $project['owner_id']); $this->assertEquals(0, $project['is_private']); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 1, 'Foobar', true)); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel'), 1, 'Foobar', true)); $project = $p->getById(2); $this->assertNotEmpty($project); @@ -179,9 +179,9 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithCategories() { - $p = new Project($this->container); - $c = new Category($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); @@ -204,10 +204,10 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithUsers() { - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); - $u = new User($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); + $u = new UserModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user1'))); $this->assertEquals(3, $u->create(array('username' => 'user2'))); @@ -229,10 +229,10 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithUsersAndOverrideOwner() { - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); - $u = new User($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); + $u = new UserModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user1'))); $this->assertEquals(1, $p->create(array('name' => 'P1'), 2)); @@ -243,7 +243,7 @@ class ProjectDuplicationTest extends Base $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MANAGER)); $this->assertTrue($pp->addUser(1, 1, Role::PROJECT_MEMBER)); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 1)); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel'), 1)); $this->assertCount(2, $pp->getUsers(2)); $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(2, 2)); @@ -255,10 +255,10 @@ class ProjectDuplicationTest extends Base public function testCloneTeamProjectToPrivatProject() { - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); - $u = new User($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); + $u = new UserModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user1'))); $this->assertEquals(3, $u->create(array('username' => 'user2'))); @@ -271,7 +271,7 @@ class ProjectDuplicationTest extends Base $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MANAGER)); $this->assertTrue($pp->addUser(1, 1, Role::PROJECT_MEMBER)); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 3, 'My private project', true)); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel'), 3, 'My private project', true)); $this->assertCount(1, $pp->getUsers(2)); $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(2, 3)); @@ -283,13 +283,13 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithGroups() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $userModel = new User($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $projectGroupRoleModel = new ProjectGroupRole($this->container); - $projectUserRoleModel = new ProjectUserRole($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $userModel = new UserModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $projectGroupRoleModel = new ProjectGroupRoleModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); @@ -319,15 +319,15 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithActionTaskAssignCurrentUser() { - $p = new Project($this->container); - $a = new Action($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $a = new ActionModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); $this->assertEquals(1, $a->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_MOVE_COLUMN, + 'event_name' => TaskModel::EVENT_MOVE_COLUMN, 'action_name' => 'TaskAssignCurrentUser', 'params' => array('column_id' => 2), ))); @@ -344,10 +344,10 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithActionTaskAssignColorCategory() { - $p = new Project($this->container); - $a = new Action($this->container); - $c = new Category($this->container); - $pd = new ProjectDuplication($this->container); + $p = new ProjectModel($this->container); + $a = new ActionModel($this->container); + $c = new CategoryModel($this->container); + $pd = new ProjectDuplicationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); @@ -357,7 +357,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $a->create(array( 'project_id' => 1, - 'event_name' => Task::EVENT_CREATE_UPDATE, + 'event_name' => TaskModel::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'blue', 'category_id' => 2), ))); @@ -375,11 +375,11 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithSwimlanes() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $s = new Swimlane($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $s = new SwimlaneModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1', 'default_swimlane' => 'New Default'))); @@ -394,7 +394,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(3, $tc->create(array('title' => 'T2', 'project_id' => 1, 'swimlane_id' => 2))); $this->assertEquals(4, $tc->create(array('title' => 'T3', 'project_id' => 1, 'swimlane_id' => 3))); - $this->assertEquals(2, $pd->duplicate(1, array('category', 'swimlane'))); + $this->assertEquals(2, $pd->duplicate(1, array('categoryModel', 'swimlaneModel'))); $swimlanes = $s->getAll(2); $this->assertCount(3, $swimlanes); @@ -414,10 +414,10 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithTasks() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); @@ -426,7 +426,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2))); $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3))); - $this->assertEquals(2, $pd->duplicate(1, array('category', 'action', 'task'))); + $this->assertEquals(2, $pd->duplicate(1, array('categoryModel', 'actionModel', 'taskModel'))); // Check if Tasks have been duplicated $tasks = $tf->getAll(2); @@ -438,11 +438,11 @@ class ProjectDuplicationTest extends Base public function testCloneProjectWithSwimlanesAndTasks() { - $p = new Project($this->container); - $pd = new ProjectDuplication($this->container); - $s = new Swimlane($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $pd = new ProjectDuplicationModel($this->container); + $s = new SwimlaneModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1', 'default_swimlane' => 'New Default'))); @@ -456,7 +456,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(2, $pd->duplicate(1, array('projectPermission', 'swimlane', 'task'))); + $this->assertEquals(2, $pd->duplicate(1, array('projectPermissionModel', 'swimlaneModel', 'taskModel'))); // Check if Swimlanes have been duplicated $swimlanes = $s->getAll(2); diff --git a/tests/units/Model/ProjectFileTest.php b/tests/units/Model/ProjectFileTest.php index 0d7a9377..116dd3d2 100644 --- a/tests/units/Model/ProjectFileTest.php +++ b/tests/units/Model/ProjectFileTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\ProjectFile; -use Kanboard\Model\Project; +use Kanboard\Model\ProjectFileModel; +use Kanboard\Model\ProjectModel; class ProjectFileTest extends Base { public function testCreation() { - $projectModel = new Project($this->container); - $fileModel = new ProjectFile($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $fileModel->create(1, 'test', '/tmp/foo', 10)); @@ -34,8 +34,8 @@ class ProjectFileTest extends Base public function testCreationWithFileNameTooLong() { - $projectModel = new Project($this->container); - $fileModel = new ProjectFile($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -54,8 +54,8 @@ class ProjectFileTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $fileModel = new ProjectFile($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $fileModel->create(1, 'test', '/tmp/foo', 10)); @@ -67,8 +67,8 @@ class ProjectFileTest extends Base public function testGetAll() { - $projectModel = new Project($this->container); - $fileModel = new ProjectFile($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -100,13 +100,13 @@ class ProjectFileTest extends Base public function testGetThumbnailPath() { - $fileModel = new ProjectFile($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertEquals('thumbnails'.DIRECTORY_SEPARATOR.'test', $fileModel->getThumbnailPath('test')); } public function testGeneratePath() { - $fileModel = new ProjectFile($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertStringStartsWith('projects'.DIRECTORY_SEPARATOR.'34'.DIRECTORY_SEPARATOR, $fileModel->generatePath(34, 'test.png')); $this->assertNotEquals($fileModel->generatePath(34, 'test1.png'), $fileModel->generatePath(34, 'test2.png')); @@ -115,12 +115,12 @@ class ProjectFileTest extends Base public function testUploadFiles() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\ProjectFile') + ->getMockBuilder('\Kanboard\Model\ProjectFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromFile')) ->getMock(); - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -181,7 +181,7 @@ class ProjectFileTest extends Base public function testUploadFilesWithEmptyFiles() { - $fileModel = new ProjectFile($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, array())); } @@ -206,7 +206,7 @@ class ProjectFileTest extends Base ), ); - $fileModel = new ProjectFile($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, $files)); } @@ -237,19 +237,19 @@ class ProjectFileTest extends Base ->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything()) ->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test'))); - $fileModel = new ProjectFile($this->container); + $fileModel = new ProjectFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, $files)); } public function testUploadFileContent() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\ProjectFile') + ->getMockBuilder('\Kanboard\Model\ProjectFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromFile')) ->getMock(); - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $data = 'test'; $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -276,12 +276,12 @@ class ProjectFileTest extends Base public function testUploadImageContent() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\ProjectFile') + ->getMockBuilder('\Kanboard\Model\ProjectFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromData')) ->getMock(); - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $data = 'test'; $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); diff --git a/tests/units/Model/ProjectGroupRoleTest.php b/tests/units/Model/ProjectGroupRoleTest.php index e38e812a..e703d4a9 100644 --- a/tests/units/Model/ProjectGroupRoleTest.php +++ b/tests/units/Model/ProjectGroupRoleTest.php @@ -2,21 +2,21 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; -use Kanboard\Model\ProjectGroupRole; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; +use Kanboard\Model\ProjectGroupRoleModel; use Kanboard\Core\Security\Role; class ProjectGroupRoleTest extends Base { public function testGetUserRole() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Group A')); @@ -30,9 +30,9 @@ class ProjectGroupRoleTest extends Base public function testAddGroup() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Test')); @@ -49,9 +49,9 @@ class ProjectGroupRoleTest extends Base public function testRemoveGroup() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Test')); @@ -65,9 +65,9 @@ class ProjectGroupRoleTest extends Base public function testChangeRole() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Test')); @@ -84,9 +84,9 @@ class ProjectGroupRoleTest extends Base public function testGetGroups() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Group C')); @@ -115,11 +115,11 @@ class ProjectGroupRoleTest extends Base public function testGetUsers() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -164,11 +164,11 @@ class ProjectGroupRoleTest extends Base public function testGetAssignableUsers() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -206,11 +206,11 @@ class ProjectGroupRoleTest extends Base public function testGetAssignableUsersWithDisabledUsers() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -244,11 +244,11 @@ class ProjectGroupRoleTest extends Base public function testGetProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -290,11 +290,11 @@ class ProjectGroupRoleTest extends Base public function testGetActiveProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_active' => 0))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -317,27 +317,27 @@ class ProjectGroupRoleTest extends Base $this->assertTrue($groupRoleModel->addGroup(2, 2, Role::PROJECT_MEMBER)); $this->assertTrue($groupRoleModel->addGroup(1, 3, Role::PROJECT_MANAGER)); - $projects = $groupRoleModel->getProjectsByUser(2, array(Project::ACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(2, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $groupRoleModel->getProjectsByUser(3, array(Project::ACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(3, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $groupRoleModel->getProjectsByUser(4, array(Project::ACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(4, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $groupRoleModel->getProjectsByUser(5, array(Project::ACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(5, array(ProjectModel::ACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 2', $projects[2]); } public function testGetInactiveProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_active' => 0))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -360,29 +360,29 @@ class ProjectGroupRoleTest extends Base $this->assertTrue($groupRoleModel->addGroup(2, 2, Role::PROJECT_MEMBER)); $this->assertTrue($groupRoleModel->addGroup(1, 3, Role::PROJECT_MANAGER)); - $projects = $groupRoleModel->getProjectsByUser(2, array(Project::INACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(2, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $groupRoleModel->getProjectsByUser(3, array(Project::INACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(3, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $groupRoleModel->getProjectsByUser(4, array(Project::INACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(4, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $groupRoleModel->getProjectsByUser(5, array(Project::INACTIVE)); + $projects = $groupRoleModel->getProjectsByUser(5, array(ProjectModel::INACTIVE)); $this->assertCount(0, $projects); } public function testUserInMultipleGroupsShouldReturnHighestRole() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(2, $userModel->create(array('username' => 'My user'))); diff --git a/tests/units/Model/ProjectMetadataTest.php b/tests/units/Model/ProjectMetadataTest.php index 16f49033..2f6d111a 100644 --- a/tests/units/Model/ProjectMetadataTest.php +++ b/tests/units/Model/ProjectMetadataTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectMetadata; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectMetadataModel; class ProjectMetadataTest extends Base { public function testOperations() { - $projectModel = new Project($this->container); - $projectMetadataModel = new ProjectMetadata($this->container); + $projectModel = new ProjectModel($this->container); + $projectMetadataModel = new ProjectMetadataModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'project #1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'project #2'))); @@ -39,8 +39,8 @@ class ProjectMetadataTest extends Base public function testAutomaticRemove() { - $projectModel = new Project($this->container); - $projectMetadataModel = new ProjectMetadata($this->container); + $projectModel = new ProjectModel($this->container); + $projectMetadataModel = new ProjectMetadataModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'project #1'))); $this->assertTrue($projectMetadataModel->save(1, array('key1' => 'value1'))); @@ -52,8 +52,8 @@ class ProjectMetadataTest extends Base public function testDuplicate() { - $projectModel = new Project($this->container); - $projectMetadataModel = new ProjectMetadata($this->container); + $projectModel = new ProjectModel($this->container); + $projectMetadataModel = new ProjectMetadataModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'project #1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'project #2'))); diff --git a/tests/units/Model/ProjectNotificationTypeTest.php b/tests/units/Model/ProjectNotificationTypeTest.php index 71e2b964..7f735828 100644 --- a/tests/units/Model/ProjectNotificationTypeTest.php +++ b/tests/units/Model/ProjectNotificationTypeTest.php @@ -2,14 +2,14 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectNotificationType; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectNotificationTypeModel; class ProjectNotificationTypeTest extends Base { public function testGetTypes() { - $nt = new ProjectNotificationType($this->container); + $nt = new ProjectNotificationTypeModel($this->container); $this->assertEmpty($nt->getTypes()); $nt->setType('foo', 'Foo', 'Something1'); @@ -22,8 +22,8 @@ class ProjectNotificationTypeTest extends Base public function testGetSelectedTypes() { - $nt = new ProjectNotificationType($this->container); - $p = new Project($this->container); + $nt = new ProjectNotificationTypeModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); diff --git a/tests/units/Model/ProjectPermissionTest.php b/tests/units/Model/ProjectPermissionTest.php index f88796b4..c9e0a481 100644 --- a/tests/units/Model/ProjectPermissionTest.php +++ b/tests/units/Model/ProjectPermissionTest.php @@ -2,26 +2,26 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\ProjectPermission; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; -use Kanboard\Model\ProjectGroupRole; -use Kanboard\Model\ProjectUserRole; +use Kanboard\Model\ProjectPermissionModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; +use Kanboard\Model\ProjectGroupRoleModel; +use Kanboard\Model\ProjectUserRoleModel; use Kanboard\Core\Security\Role; class ProjectPermissionTest extends Base { public function testFindByUsernames() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermissionModel = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermissionModel = new ProjectPermissionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); @@ -42,10 +42,10 @@ class ProjectPermissionTest extends Base public function testGetQueryByRole() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($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'))); @@ -105,8 +105,8 @@ class ProjectPermissionTest extends Base public function testEverybodyAllowed() { - $projectModel = new Project($this->container); - $projectPermission = new ProjectPermission($this->container); + $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))); @@ -117,13 +117,13 @@ class ProjectPermissionTest extends Base public function testIsUserAllowed() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user 2'))); @@ -154,13 +154,13 @@ class ProjectPermissionTest extends Base public function testIsAssignable() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user 2'))); @@ -191,10 +191,10 @@ class ProjectPermissionTest extends Base public function testIsAssignableWhenUserIsDisabled() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user 2', 'is_active' => 0))); @@ -210,13 +210,13 @@ class ProjectPermissionTest extends Base public function testIsMember() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user 2'))); @@ -247,10 +247,10 @@ class ProjectPermissionTest extends Base public function testGetActiveProjectIds() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); $this->assertEquals(3, $userModel->create(array('username' => 'user 2'))); @@ -269,13 +269,13 @@ class ProjectPermissionTest extends Base public function testDuplicate() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $projectPermission = new ProjectPermission($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $userRoleModel = new ProjectUserRoleModel($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'))); diff --git a/tests/units/Model/ProjectTest.php b/tests/units/Model/ProjectTest.php index 6c50744b..472d7351 100644 --- a/tests/units/Model/ProjectTest.php +++ b/tests/units/Model/ProjectTest.php @@ -4,20 +4,20 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Core\Translator; use Kanboard\Subscriber\ProjectModificationDateSubscriber; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Config; -use Kanboard\Model\Category; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\CategoryModel; class ProjectTest extends Base { public function testCreationForAllLanguages() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); - foreach ($this->container['language']->getLanguages() as $locale => $language) { + foreach ($this->container['languageModel']->getLanguages() as $locale => $language) { Translator::unload(); Translator::load($locale); $this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language); @@ -28,7 +28,7 @@ class ProjectTest extends Base public function testCreation() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); @@ -43,7 +43,7 @@ class ProjectTest extends Base public function testCreationWithDuplicateName() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest'))); @@ -51,7 +51,7 @@ class ProjectTest extends Base public function testCreationWithStartAndDate() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest', 'start_date' => '2015-01-01', 'end_date' => '2015-12-31'))); @@ -63,9 +63,9 @@ class ProjectTest extends Base public function testCreationWithDefaultCategories() { - $p = new Project($this->container); - $c = new Config($this->container); - $cat = new Category($this->container); + $p = new ProjectModel($this->container); + $c = new ConfigModel($this->container); + $cat = new CategoryModel($this->container); // Multiple categories correctly formatted @@ -124,7 +124,7 @@ class ProjectTest extends Base public function testUpdateLastModifiedDate() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $now = time(); @@ -143,7 +143,7 @@ class ProjectTest extends Base public function testGetAllIds() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); @@ -154,8 +154,8 @@ class ProjectTest extends Base public function testIsLastModified() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $now = time(); @@ -168,12 +168,12 @@ class ProjectTest extends Base sleep(1); $listener = new ProjectModificationDateSubscriber($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, array($listener, 'execute')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, array($listener, 'execute')); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.Kanboard\Subscriber\ProjectModificationDateSubscriber::execute', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.Kanboard\Subscriber\ProjectModificationDateSubscriber::execute', $called); $project = $p->getById(1); $this->assertNotEmpty($project); @@ -182,7 +182,7 @@ class ProjectTest extends Base public function testRemove() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($p->remove(1)); @@ -191,7 +191,7 @@ class ProjectTest extends Base public function testEnable() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($p->disable(1)); @@ -205,7 +205,7 @@ class ProjectTest extends Base public function testDisable() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($p->disable(1)); @@ -220,7 +220,7 @@ class ProjectTest extends Base public function testEnablePublicAccess() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($p->enablePublicAccess(1)); @@ -235,7 +235,7 @@ class ProjectTest extends Base public function testDisablePublicAccess() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($p->enablePublicAccess(1)); @@ -251,7 +251,7 @@ class ProjectTest extends Base public function testIdentifier() { - $p = new Project($this->container); + $p = new ProjectModel($this->container); // Creation $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1'))); @@ -282,8 +282,8 @@ class ProjectTest extends Base public function testThatProjectCreatorAreAlsoOwner() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'Me'))); $this->assertEquals(1, $projectModel->create(array('name' => 'My project 1'), 2)); @@ -306,7 +306,7 @@ class ProjectTest extends Base public function testPriority() { - $projectModel = new Project($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'My project 2'))); $project = $projectModel->getById(1); diff --git a/tests/units/Model/ProjectUserRoleTest.php b/tests/units/Model/ProjectUserRoleTest.php index 0e06ac5e..d59b15c9 100644 --- a/tests/units/Model/ProjectUserRoleTest.php +++ b/tests/units/Model/ProjectUserRoleTest.php @@ -2,21 +2,21 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; -use Kanboard\Model\ProjectGroupRole; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\ProjectPermission; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; +use Kanboard\Model\ProjectGroupRoleModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\ProjectPermissionModel; use Kanboard\Core\Security\Role; class ProjectUserRoleTest extends Base { public function testAddUser() { - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); @@ -33,8 +33,8 @@ class ProjectUserRoleTest extends Base public function testRemoveUser() { - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); @@ -47,8 +47,8 @@ class ProjectUserRoleTest extends Base public function testChangeRole() { - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); @@ -65,8 +65,8 @@ class ProjectUserRoleTest extends Base public function testGetRole() { - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEmpty($userRoleModel->getUserRole(1, 1)); @@ -85,11 +85,11 @@ class ProjectUserRoleTest extends Base public function testGetRoleWithGroups() { - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $groupModel->create('Group A')); @@ -103,9 +103,9 @@ class ProjectUserRoleTest extends Base public function testGetRoleWithPublicProject() { - $projectModel = new Project($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $userModel = new User($this->container); + $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'))); @@ -123,9 +123,9 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersWithDisabledUsers() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1'))); @@ -153,9 +153,9 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersWithoutGroups() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1'))); @@ -174,12 +174,12 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersWithGroups() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $groupModel = new Group($this->container); - $userRoleModel = new ProjectUserRole($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $groupMemberModel = new GroupMember($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + $groupModel = new GroupModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); @@ -211,9 +211,9 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersList() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Test2'))); @@ -249,9 +249,9 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersWithEverybodyAllowed() { - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $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))); @@ -272,10 +272,10 @@ class ProjectUserRoleTest extends Base public function testGetAssignableUsersWithDisabledUsersAndEverybodyAllowed() { - $projectModel = new Project($this->container); - $projectPermission = new ProjectPermission($this->container); - $userModel = new User($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $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'))); @@ -302,12 +302,12 @@ class ProjectUserRoleTest extends Base public function testGetProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -364,12 +364,12 @@ class ProjectUserRoleTest extends Base public function testGetActiveProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_active' => 0))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -398,36 +398,36 @@ class ProjectUserRoleTest extends Base $this->assertTrue($userRoleModel->addUser(2, 6, Role::PROJECT_MEMBER)); $this->assertTrue($userRoleModel->addUser(2, 7, Role::PROJECT_MEMBER)); - $projects = $userRoleModel->getProjectsByUser(2, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(2, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $userRoleModel->getProjectsByUser(3, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(3, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $userRoleModel->getProjectsByUser(4, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(4, array(ProjectModel::ACTIVE)); $this->assertCount(0, $projects); - $projects = $userRoleModel->getProjectsByUser(5, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(5, array(ProjectModel::ACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 2', $projects[2]); - $projects = $userRoleModel->getProjectsByUser(6, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(6, array(ProjectModel::ACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 2', $projects[2]); - $projects = $userRoleModel->getProjectsByUser(7, array(Project::ACTIVE)); + $projects = $userRoleModel->getProjectsByUser(7, array(ProjectModel::ACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 2', $projects[2]); } public function testGetInactiveProjectsByUser() { - $userModel = new User($this->container); - $projectModel = new Project($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $groupRoleModel = new ProjectGroupRole($this->container); - $userRoleModel = new ProjectUserRole($this->container); + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $groupRoleModel = new ProjectGroupRoleModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_active' => 0))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2'))); @@ -456,26 +456,26 @@ class ProjectUserRoleTest extends Base $this->assertTrue($userRoleModel->addUser(2, 6, Role::PROJECT_MEMBER)); $this->assertTrue($userRoleModel->addUser(2, 7, Role::PROJECT_MEMBER)); - $projects = $userRoleModel->getProjectsByUser(2, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(2, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $userRoleModel->getProjectsByUser(3, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(3, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $userRoleModel->getProjectsByUser(4, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(4, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $userRoleModel->getProjectsByUser(5, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(5, array(ProjectModel::INACTIVE)); $this->assertCount(0, $projects); - $projects = $userRoleModel->getProjectsByUser(6, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(6, array(ProjectModel::INACTIVE)); $this->assertCount(1, $projects); $this->assertEquals('Project 1', $projects[1]); - $projects = $userRoleModel->getProjectsByUser(7, array(Project::INACTIVE)); + $projects = $userRoleModel->getProjectsByUser(7, array(ProjectModel::INACTIVE)); $this->assertCount(0, $projects); } } diff --git a/tests/units/Model/SubtaskTest.php b/tests/units/Model/SubtaskTest.php index 20186452..b65ee609 100644 --- a/tests/units/Model/SubtaskTest.php +++ b/tests/units/Model/SubtaskTest.php @@ -2,11 +2,11 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Subtask; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\ProjectModel; use Kanboard\Core\User\UserSession; -use Kanboard\Model\TaskFinder; +use Kanboard\Model\TaskFinderModel; class SubtaskTest extends Base { @@ -46,7 +46,7 @@ class SubtaskTest extends Base $this->assertArrayHasKey('user_id', $data['changes']); $this->assertArrayHasKey('status', $data['changes']); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $data['changes']['status']); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $data['changes']['status']); $this->assertEquals(1, $data['changes']['user_id']); } @@ -70,14 +70,14 @@ class SubtaskTest extends Base public function testCreation() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); - $this->container['dispatcher']->addListener(Subtask::EVENT_CREATE, array($this, 'onSubtaskCreated')); + $this->container['dispatcher']->addListener(SubtaskModel::EVENT_CREATE, array($this, 'onSubtaskCreated')); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); @@ -86,7 +86,7 @@ class SubtaskTest extends Base $this->assertEquals(1, $subtask['id']); $this->assertEquals(1, $subtask['task_id']); $this->assertEquals('subtask #1', $subtask['title']); - $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_TODO, $subtask['status']); $this->assertEquals(0, $subtask['time_estimated']); $this->assertEquals(0, $subtask['time_spent']); $this->assertEquals(0, $subtask['user_id']); @@ -95,24 +95,24 @@ class SubtaskTest extends Base public function testModification() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); - $this->container['dispatcher']->addListener(Subtask::EVENT_UPDATE, array($this, 'onSubtaskUpdated')); + $this->container['dispatcher']->addListener(SubtaskModel::EVENT_UPDATE, array($this, 'onSubtaskUpdated')); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); - $this->assertTrue($s->update(array('id' => 1, 'user_id' => 1, 'status' => Subtask::STATUS_INPROGRESS))); + $this->assertTrue($s->update(array('id' => 1, 'user_id' => 1, 'status' => SubtaskModel::STATUS_INPROGRESS))); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['id']); $this->assertEquals(1, $subtask['task_id']); $this->assertEquals('subtask #1', $subtask['title']); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $subtask['status']); $this->assertEquals(0, $subtask['time_estimated']); $this->assertEquals(0, $subtask['time_spent']); $this->assertEquals(1, $subtask['user_id']); @@ -121,15 +121,15 @@ class SubtaskTest extends Base public function testRemove() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); - $this->container['dispatcher']->addListener(Subtask::EVENT_DELETE, array($this, 'onSubtaskDeleted')); + $this->container['dispatcher']->addListener(SubtaskModel::EVENT_DELETE, array($this, 'onSubtaskDeleted')); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); @@ -142,9 +142,9 @@ class SubtaskTest extends Base public function testToggleStatusWithoutSession() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); @@ -153,40 +153,40 @@ class SubtaskTest extends Base $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_TODO, $subtask['status']); $this->assertEquals(0, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $subtask['status']); $this->assertEquals(0, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); - $this->assertEquals(Subtask::STATUS_DONE, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_DONE, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']); $this->assertEquals(0, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); - $this->assertEquals(Subtask::STATUS_TODO, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_TODO, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_TODO, $subtask['status']); $this->assertEquals(0, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); } public function testToggleStatusWithSession() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $us = new UserSession($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -196,43 +196,43 @@ class SubtaskTest extends Base $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_TODO, $subtask['status']); $this->assertEquals(0, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); // Set the current logged user $this->container['sessionStorage']->user = array('id' => 1); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_INPROGRESS, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $subtask['status']); $this->assertEquals(1, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); - $this->assertEquals(Subtask::STATUS_DONE, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_DONE, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']); $this->assertEquals(1, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); - $this->assertEquals(Subtask::STATUS_TODO, $s->toggleStatus(1)); + $this->assertEquals(SubtaskModel::STATUS_TODO, $s->toggleStatus(1)); $subtask = $s->getById(1); $this->assertNotEmpty($subtask); - $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_TODO, $subtask['status']); $this->assertEquals(1, $subtask['user_id']); $this->assertEquals(1, $subtask['task_id']); } public function testCloseAll() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); @@ -246,15 +246,15 @@ class SubtaskTest extends Base $this->assertNotEmpty($subtasks); foreach ($subtasks as $subtask) { - $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']); } } public function testDuplicate() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); // We create a project $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -299,9 +299,9 @@ class SubtaskTest extends Base public function testChangePosition() { - $taskCreationModel = new TaskCreation($this->container); - $subtaskModel = new Subtask($this->container); - $projectModel = new Project($this->container); + $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))); @@ -364,10 +364,10 @@ class SubtaskTest extends Base public function testConvertToTask() { - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); - $subtaskModel = new Subtask($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($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))); diff --git a/tests/units/Model/SubtaskTimeTrackingTest.php b/tests/units/Model/SubtaskTimeTrackingTest.php index dead3887..d5ae62ae 100644 --- a/tests/units/Model/SubtaskTimeTrackingTest.php +++ b/tests/units/Model/SubtaskTimeTrackingTest.php @@ -2,20 +2,20 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Subtask; -use Kanboard\Model\SubtaskTimeTracking; -use Kanboard\Model\Project; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\SubtaskTimeTrackingModel; +use Kanboard\Model\ProjectModel; class SubtaskTimeTrackingTest extends Base { public function testHasTimer() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); @@ -31,10 +31,10 @@ class SubtaskTimeTrackingTest extends Base public function testGetTimerStatus() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->container['sessionStorage']->user = array('id' => 1); @@ -81,10 +81,10 @@ class SubtaskTimeTrackingTest extends Base public function testLogStartTime() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); @@ -103,10 +103,10 @@ class SubtaskTimeTrackingTest extends Base public function testLogStartEnd() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); @@ -134,10 +134,10 @@ class SubtaskTimeTrackingTest extends Base public function testCalculateSubtaskTime() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); @@ -152,10 +152,10 @@ class SubtaskTimeTrackingTest extends Base public function testUpdateSubtaskTimeSpent() { - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); @@ -166,7 +166,7 @@ class SubtaskTimeTrackingTest extends Base $this->assertTrue($st->logStartTime(2, 1)); // Fake start time - $this->container['db']->table(SubtaskTimeTracking::TABLE)->update(array('start' => time() - 3600)); + $this->container['db']->table(SubtaskTimeTrackingModel::TABLE)->update(array('start' => time() - 3600)); $this->assertTrue($st->logEndTime(1, 1)); $this->assertTrue($st->logEndTime(2, 1)); @@ -188,11 +188,11 @@ class SubtaskTimeTrackingTest extends Base public function testUpdateTaskTimeTracking() { - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $st = new SubtaskTimeTracking($this->container); - $p = new Project($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $st = new SubtaskTimeTrackingModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); diff --git a/tests/units/Model/SwimlaneTest.php b/tests/units/Model/SwimlaneTest.php index 380d8c77..2594b17a 100644 --- a/tests/units/Model/SwimlaneTest.php +++ b/tests/units/Model/SwimlaneTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Swimlane; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\SwimlaneModel; class SwimlaneTest extends Base { public function testCreation() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -32,8 +32,8 @@ class SwimlaneTest extends Base public function testGetList() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -47,8 +47,8 @@ class SwimlaneTest extends Base public function testUpdate() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -66,8 +66,8 @@ class SwimlaneTest extends Base public function testUpdateDefaultSwimlane() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertTrue($s->updateDefault(array('id' => 1, 'default_swimlane' => 'foo', 'show_default_swimlane' => 1))); @@ -87,8 +87,8 @@ class SwimlaneTest extends Base public function testDisableEnableDefaultSwimlane() { - $projectModel = new Project($this->container); - $swimlaneModel = new Swimlane($this->container); + $projectModel = new ProjectModel($this->container); + $swimlaneModel = new SwimlaneModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); @@ -103,8 +103,8 @@ class SwimlaneTest extends Base public function testDisableEnable() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -143,10 +143,10 @@ class SwimlaneTest extends Base public function testRemove() { - $p = new Project($this->container); - $s = new Swimlane($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -167,8 +167,8 @@ class SwimlaneTest extends Base public function testUpdatePositions() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -227,8 +227,8 @@ class SwimlaneTest extends Base public function testDuplicateSwimlane() { - $p = new Project($this->container); - $s = new Swimlane($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); $this->assertEquals(2, $p->create(array('name' => 'P2'))); @@ -258,8 +258,8 @@ class SwimlaneTest extends Base public function testChangePosition() { - $projectModel = new Project($this->container); - $swimlaneModel = new Swimlane($this->container); + $projectModel = new ProjectModel($this->container); + $swimlaneModel = new SwimlaneModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); @@ -321,8 +321,8 @@ class SwimlaneTest extends Base public function testChangePositionWithInactiveSwimlane() { - $projectModel = new Project($this->container); - $swimlaneModel = new Swimlane($this->container); + $projectModel = new ProjectModel($this->container); + $swimlaneModel = new SwimlaneModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); diff --git a/tests/units/Model/TaskCreationTest.php b/tests/units/Model/TaskCreationTest.php index d6860b30..aba52ae2 100644 --- a/tests/units/Model/TaskCreationTest.php +++ b/tests/units/Model/TaskCreationTest.php @@ -2,11 +2,11 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Config; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; class TaskCreationTest extends Base { @@ -22,36 +22,36 @@ class TaskCreationTest extends Base public function testNoProjectId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(0, $tc->create(array('title' => 'test', 'project_id' => 0))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayNotHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayNotHasKey(Task::EVENT_CREATE.'.closure', $called); + $this->assertArrayNotHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayNotHasKey(TaskModel::EVENT_CREATE.'.closure', $called); } public function testNoTitle() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayHasKey(Task::EVENT_CREATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.closure', $called); $task = $tf->getById(1); $this->assertNotEmpty($task); @@ -62,19 +62,19 @@ class TaskCreationTest extends Base public function testMinimum() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, array($this, 'onCreate')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, array($this, 'onCreate')); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayHasKey(Task::EVENT_CREATE.'.TaskCreationTest::onCreate', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.TaskCreationTest::onCreate', $called); $task = $tf->getById(1); $this->assertNotEmpty($task); @@ -108,9 +108,9 @@ class TaskCreationTest extends Base public function testColorId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'color_id' => 'blue'))); @@ -124,9 +124,9 @@ class TaskCreationTest extends Base public function testOwnerId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 1))); @@ -140,9 +140,9 @@ class TaskCreationTest extends Base public function testCategoryId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'category_id' => 1))); @@ -156,9 +156,9 @@ class TaskCreationTest extends Base public function testCreatorId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'creator_id' => 1))); @@ -172,9 +172,9 @@ class TaskCreationTest extends Base public function testThatCreatorIsDefined() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->container['sessionStorage']->user = array('id' => 1); @@ -190,9 +190,9 @@ class TaskCreationTest extends Base public function testColumnId() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2))); @@ -207,9 +207,9 @@ class TaskCreationTest extends Base public function testPosition() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2))); @@ -233,9 +233,9 @@ class TaskCreationTest extends Base public function testDescription() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'description' => 'test'))); @@ -249,9 +249,9 @@ class TaskCreationTest extends Base public function testReference() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'reference' => 'test'))); @@ -267,9 +267,9 @@ class TaskCreationTest extends Base { $date = '2014-11-23'; $timestamp = strtotime('+2days'); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_due' => $date))); @@ -293,9 +293,9 @@ class TaskCreationTest extends Base public function testDateStarted() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); @@ -331,9 +331,9 @@ class TaskCreationTest extends Base public function testTime() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($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))); @@ -348,9 +348,9 @@ class TaskCreationTest extends Base public function testStripColumn() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'another_task' => '1'))); @@ -361,9 +361,9 @@ class TaskCreationTest extends Base public function testScore() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'score' => '3'))); @@ -376,10 +376,10 @@ class TaskCreationTest extends Base public function testDefaultColor() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $c = new Config($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $c = new ConfigModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test1'))); @@ -400,9 +400,9 @@ class TaskCreationTest extends Base public function testDueDateYear2038TimestampBug() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_due' => strtotime('2050-01-10 12:30')))); diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php index 8c5f5cec..79b75e54 100644 --- a/tests/units/Model/TaskDuplicationTest.php +++ b/tests/units/Model/TaskDuplicationTest.php @@ -3,25 +3,25 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Core\DateParser; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskDuplication; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\Category; -use Kanboard\Model\User; -use Kanboard\Model\Swimlane; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskDuplicationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\CategoryModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\SwimlaneModel; use Kanboard\Core\Security\Role; class TaskDuplicationTest extends Base { public function testThatDuplicateDefineCreator() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -45,11 +45,11 @@ class TaskDuplicationTest extends Base public function testDuplicateSameProject() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); // We create a task and a project $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -73,20 +73,20 @@ class TaskDuplicationTest extends Base $this->assertEquals(2, $task['category_id']); $this->assertEquals(4.4, $task['time_spent']); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); // We duplicate our task $this->assertEquals(2, $td->duplicate(1)); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayHasKey(Task::EVENT_CREATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.closure', $called); // Check the values of the duplicated task $task = $tf->getById(2); $this->assertNotEmpty($task); - $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); + $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']); $this->assertEquals(1, $task['project_id']); $this->assertEquals(1, $task['owner_id']); $this->assertEquals(2, $task['category_id']); @@ -99,11 +99,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProject() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -115,15 +115,15 @@ class TaskDuplicationTest extends Base // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1))); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); // We duplicate our task to the 2nd project $this->assertEquals(2, $td->duplicateToProject(1, 2)); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayHasKey(Task::EVENT_CREATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.closure', $called); // Check the values of the duplicated task $task = $tf->getById(2); @@ -139,11 +139,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithCategory() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -174,11 +174,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithPredefinedCategory() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -213,11 +213,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithSwimlane() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -246,11 +246,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithoutSwimlane() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -279,11 +279,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithPredefinedSwimlane() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -307,10 +307,10 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithPredefinedColumn() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -330,11 +330,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithUser() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -356,7 +356,7 @@ class TaskDuplicationTest extends Base $this->assertEquals('test', $task['title']); // We create a new user for our project - $user = new User($this->container); + $user = new UserModel($this->container); $this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest'))); $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER)); $this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER)); @@ -386,11 +386,11 @@ class TaskDuplicationTest extends Base public function testDuplicateAnotherProjectWithPredefinedUser() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $pr = new ProjectUserRole($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $pr = new ProjectUserRoleModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -421,11 +421,11 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProject() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $user = new User($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $user = new UserModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -434,13 +434,13 @@ class TaskDuplicationTest extends Base // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333))); - $this->container['dispatcher']->addListener(Task::EVENT_MOVE_PROJECT, array($this, 'onMoveProject')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_MOVE_PROJECT, array($this, 'onMoveProject')); // We duplicate our task to the 2nd project $this->assertTrue($td->moveToProject(1, 2)); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_MOVE_PROJECT.'.TaskDuplicationTest::onMoveProject', $called); + $this->assertArrayHasKey(TaskModel::EVENT_MOVE_PROJECT.'.TaskDuplicationTest::onMoveProject', $called); // Check the values of the moved task $task = $tf->getById(1); @@ -456,11 +456,11 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProjectWithCategory() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $c = new CategoryModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -491,12 +491,12 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProjectWithUser() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); - $user = new User($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); + $user = new UserModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -524,12 +524,12 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProjectWithForbiddenUser() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $pp = new ProjectUserRole($this->container); - $user = new User($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $pp = new ProjectUserRoleModel($this->container); + $user = new UserModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -557,11 +557,11 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProjectWithSwimlane() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -590,11 +590,11 @@ class TaskDuplicationTest extends Base public function testMoveAnotherProjectWithoutSwimlane() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -623,47 +623,47 @@ class TaskDuplicationTest extends Base public function testCalculateRecurringTaskDueDate() { - $td = new TaskDuplication($this->container); + $td = new TaskDuplicationModel($this->container); $values = array('date_due' => 0); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(0, $values['date_due']); - $values = array('date_due' => 0, 'recurrence_factor' => 0, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS); + $values = array('date_due' => 0, 'recurrence_factor' => 0, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(0, $values['date_due']); - $values = array('date_due' => 1431291376, 'recurrence_factor' => 1, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => 1, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(time() + 86400, $values['date_due'], '', 1); - $values = array('date_due' => 1431291376, 'recurrence_factor' => -2, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => -2, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_TRIGGERDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(time() - 2 * 86400, $values['date_due'], '', 1); - $values = array('date_due' => 1431291376, 'recurrence_factor' => 1, 'recurrence_basedate' => Task::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => 1, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(1431291376 + 86400, $values['date_due'], '', 1); - $values = array('date_due' => 1431291376, 'recurrence_factor' => -1, 'recurrence_basedate' => Task::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => -1, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(1431291376 - 86400, $values['date_due'], '', 1); - $values = array('date_due' => 1431291376, 'recurrence_factor' => 2, 'recurrence_basedate' => Task::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_MONTHS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => 2, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_MONTHS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(1436561776, $values['date_due'], '', 1); - $values = array('date_due' => 1431291376, 'recurrence_factor' => 2, 'recurrence_basedate' => Task::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_YEARS); + $values = array('date_due' => 1431291376, 'recurrence_factor' => 2, 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_DUEDATE, 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_YEARS); $td->calculateRecurringTaskDueDate($values); $this->assertEquals(1494449776, $values['date_due'], '', 1); } public function testDuplicateRecurringTask() { - $td = new TaskDuplication($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $td = new TaskDuplicationModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $dp = new DateParser($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); @@ -672,27 +672,27 @@ class TaskDuplicationTest extends Base 'title' => 'test', 'project_id' => 1, 'date_due' => 1436561776, - 'recurrence_status' => Task::RECURRING_STATUS_PENDING, - 'recurrence_trigger' => Task::RECURRING_TRIGGER_CLOSE, + 'recurrence_status' => TaskModel::RECURRING_STATUS_PENDING, + 'recurrence_trigger' => TaskModel::RECURRING_TRIGGER_CLOSE, 'recurrence_factor' => 2, - 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS, - 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE, + 'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS, + 'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_TRIGGERDATE, ))); $this->assertEquals(2, $td->duplicateRecurringTask(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(Task::RECURRING_STATUS_PROCESSED, $task['recurrence_status']); + $this->assertEquals(TaskModel::RECURRING_STATUS_PROCESSED, $task['recurrence_status']); $this->assertEquals(2, $task['recurrence_child']); $this->assertEquals(1436486400, $task['date_due'], '', 2); $task = $tf->getById(2); $this->assertNotEmpty($task); - $this->assertEquals(Task::RECURRING_STATUS_PENDING, $task['recurrence_status']); - $this->assertEquals(Task::RECURRING_TRIGGER_CLOSE, $task['recurrence_trigger']); - $this->assertEquals(Task::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']); - $this->assertEquals(Task::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']); + $this->assertEquals(TaskModel::RECURRING_STATUS_PENDING, $task['recurrence_status']); + $this->assertEquals(TaskModel::RECURRING_TRIGGER_CLOSE, $task['recurrence_trigger']); + $this->assertEquals(TaskModel::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']); + $this->assertEquals(TaskModel::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']); $this->assertEquals(1, $task['recurrence_parent']); $this->assertEquals(2, $task['recurrence_factor']); $this->assertEquals($dp->removeTimeFromTimestamp(strtotime('+2 days')), $task['date_due'], '', 2); diff --git a/tests/units/Model/TaskExternalLinkTest.php b/tests/units/Model/TaskExternalLinkTest.php index 3a79ff82..1327b6e1 100644 --- a/tests/units/Model/TaskExternalLinkTest.php +++ b/tests/units/Model/TaskExternalLinkTest.php @@ -2,9 +2,9 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\TaskExternalLink; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskExternalLinkModel; use Kanboard\Core\ExternalLink\ExternalLinkManager; use Kanboard\ExternalLink\WebLinkProvider; @@ -12,9 +12,9 @@ class TaskExternalLinkTest extends Base { public function testCreate() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskExternalLinkModel = new TaskExternalLinkModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); @@ -35,9 +35,9 @@ class TaskExternalLinkTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskExternalLinkModel = new TaskExternalLinkModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); @@ -56,9 +56,9 @@ class TaskExternalLinkTest extends Base public function testModification() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskExternalLinkModel = new TaskExternalLinkModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); @@ -76,9 +76,9 @@ class TaskExternalLinkTest extends Base public function testRemove() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskExternalLinkModel = new TaskExternalLinkModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); @@ -95,9 +95,9 @@ class TaskExternalLinkTest extends Base $this->container['sessionStorage']->user = array('id' => 1); $this->container['externalLinkManager'] = new ExternalLinkManager($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskExternalLinkModel = new TaskExternalLinkModel($this->container); $webLinkProvider = new WebLinkProvider($this->container); $this->container['externalLinkManager']->register($webLinkProvider); diff --git a/tests/units/Model/TaskFileTest.php b/tests/units/Model/TaskFileTest.php index e44e092d..2faee95c 100644 --- a/tests/units/Model/TaskFileTest.php +++ b/tests/units/Model/TaskFileTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFile; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskFileModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; class TaskFileTest extends Base { public function testCreation() { - $projectModel = new Project($this->container); - $fileModel = new TaskFile($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new TaskFileModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -38,9 +38,9 @@ class TaskFileTest extends Base public function testCreationWithFileNameTooLong() { - $projectModel = new Project($this->container); - $fileModel = new TaskFile($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new TaskFileModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -60,9 +60,9 @@ class TaskFileTest extends Base { $this->container['sessionStorage']->user = array('id' => 1); - $projectModel = new Project($this->container); - $fileModel = new TaskFile($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new TaskFileModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -75,9 +75,9 @@ class TaskFileTest extends Base public function testGetAll() { - $projectModel = new Project($this->container); - $fileModel = new TaskFile($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $fileModel = new TaskFileModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -110,7 +110,7 @@ class TaskFileTest extends Base public function testIsImage() { - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertTrue($fileModel->isImage('test.png')); $this->assertTrue($fileModel->isImage('test.jpeg')); @@ -125,13 +125,13 @@ class TaskFileTest extends Base public function testGetThumbnailPath() { - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertEquals('thumbnails'.DIRECTORY_SEPARATOR.'test', $fileModel->getThumbnailPath('test')); } public function testGeneratePath() { - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertStringStartsWith('tasks'.DIRECTORY_SEPARATOR.'34'.DIRECTORY_SEPARATOR, $fileModel->generatePath(34, 'test.png')); $this->assertNotEquals($fileModel->generatePath(34, 'test1.png'), $fileModel->generatePath(34, 'test2.png')); @@ -140,13 +140,13 @@ class TaskFileTest extends Base public function testUploadFiles() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\TaskFile') + ->getMockBuilder('\Kanboard\Model\TaskFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromFile')) ->getMock(); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -208,7 +208,7 @@ class TaskFileTest extends Base public function testUploadFilesWithEmptyFiles() { - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, array())); } @@ -233,7 +233,7 @@ class TaskFileTest extends Base ), ); - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, $files)); } @@ -264,20 +264,20 @@ class TaskFileTest extends Base ->with($this->equalTo('/tmp/phpYzdqkD'), $this->anything()) ->will($this->throwException(new \Kanboard\Core\ObjectStorage\ObjectStorageException('test'))); - $fileModel = new TaskFile($this->container); + $fileModel = new TaskFileModel($this->container); $this->assertFalse($fileModel->uploadFiles(1, $files)); } public function testUploadFileContent() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\TaskFile') + ->getMockBuilder('\Kanboard\Model\TaskFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromFile')) ->getMock(); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $data = 'test'; $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -305,13 +305,13 @@ class TaskFileTest extends Base public function testUploadFileContentWithObjectStorageError() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\TaskFile') + ->getMockBuilder('\Kanboard\Model\TaskFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromFile')) ->getMock(); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $data = 'test'; $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -329,13 +329,13 @@ class TaskFileTest extends Base public function testUploadScreenshot() { $fileModel = $this - ->getMockBuilder('\Kanboard\Model\TaskFile') + ->getMockBuilder('\Kanboard\Model\TaskFileModel') ->setConstructorArgs(array($this->container)) ->setMethods(array('generateThumbnailFromData')) ->getMock(); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $data = 'test'; $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); @@ -366,9 +366,9 @@ class TaskFileTest extends Base public function testRemove() { - $fileModel = new TaskFile($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $fileModel = new TaskFileModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -384,9 +384,9 @@ class TaskFileTest extends Base public function testRemoveWithObjectStorageError() { - $fileModel = new TaskFile($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $fileModel = new TaskFileModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -403,9 +403,9 @@ class TaskFileTest extends Base public function testRemoveImage() { - $fileModel = new TaskFile($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $fileModel = new TaskFileModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -426,9 +426,9 @@ class TaskFileTest extends Base public function testRemoveAll() { - $fileModel = new TaskFile($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); + $fileModel = new TaskFileModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); diff --git a/tests/units/Model/TaskFinderTest.php b/tests/units/Model/TaskFinderTest.php index ef9d7830..46792baf 100644 --- a/tests/units/Model/TaskFinderTest.php +++ b/tests/units/Model/TaskFinderTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; class TaskFinderTest extends Base { public function testGetOverdueTasks() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day')))); @@ -29,9 +29,9 @@ class TaskFinderTest extends Base public function testGetOverdueTasksByProject() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(2, $p->create(array('name' => 'Project #2'))); @@ -50,9 +50,9 @@ class TaskFinderTest extends Base public function testGetOverdueTasksByUser() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(2, $p->create(array('name' => 'Project #2'))); @@ -80,9 +80,9 @@ class TaskFinderTest extends Base public function testCountByProject() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(2, $p->create(array('name' => 'Project #2'))); @@ -96,9 +96,9 @@ class TaskFinderTest extends Base public function testGetProjectToken() { - $taskCreationModel = new TaskCreation($this->container); - $taskFinderModel = new TaskFinder($this->container); - $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); diff --git a/tests/units/Model/TaskLinkTest.php b/tests/units/Model/TaskLinkTest.php index 8dd71830..bc574731 100644 --- a/tests/units/Model/TaskLinkTest.php +++ b/tests/units/Model/TaskLinkTest.php @@ -2,20 +2,20 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskLink; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskLinkModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; class TaskLinkTest extends Base { // Check postgres issue: "Cardinality violation: 7 ERROR: more than one row returned by a subquery used as an expression" public function testGetTaskWithMultipleMilestoneLink() { - $tf = new TaskFinder($this->container); - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tf = new TaskFinderModel($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); @@ -31,9 +31,9 @@ class TaskLinkTest extends Base public function testCreateTaskLinkWithNoOpposite() { - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); @@ -73,9 +73,9 @@ class TaskLinkTest extends Base public function testCreateTaskLinkWithOpposite() { - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); @@ -115,9 +115,9 @@ class TaskLinkTest extends Base public function testGroupByLabel() { - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); @@ -139,9 +139,9 @@ class TaskLinkTest extends Base public function testUpdate() { - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); @@ -172,9 +172,9 @@ class TaskLinkTest extends Base public function testRemove() { - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); diff --git a/tests/units/Model/TaskMetadataTest.php b/tests/units/Model/TaskMetadataTest.php index 2683c297..b1e7eee8 100644 --- a/tests/units/Model/TaskMetadataTest.php +++ b/tests/units/Model/TaskMetadataTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Project; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskMetadata; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskMetadataModel; class TaskMetadataTest extends Base { public function testOperations() { - $p = new Project($this->container); - $tm = new TaskMetadata($this->container); - $tc = new TaskCreation($this->container); + $p = new ProjectModel($this->container); + $tm = new TaskMetadataModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'task #1', 'project_id' => 1))); diff --git a/tests/units/Model/TaskModificationTest.php b/tests/units/Model/TaskModificationTest.php index 315125d5..022fb49b 100644 --- a/tests/units/Model/TaskModificationTest.php +++ b/tests/units/Model/TaskModificationTest.php @@ -2,11 +2,11 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskModification; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskModificationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; class TaskModificationTest extends Base { @@ -42,16 +42,16 @@ class TaskModificationTest extends Base public function testThatNoEventAreFiredWhenNoChanges() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, array($this, 'onCreateUpdate')); - $this->container['dispatcher']->addListener(Task::EVENT_UPDATE, array($this, 'onUpdate')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, array($this, 'onCreateUpdate')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_UPDATE, array($this, 'onUpdate')); $this->assertTrue($tm->update(array('id' => 1, 'title' => 'test'))); @@ -60,22 +60,22 @@ class TaskModificationTest extends Base public function testChangeTitle() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, array($this, 'onCreateUpdate')); - $this->container['dispatcher']->addListener(Task::EVENT_UPDATE, array($this, 'onUpdate')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, array($this, 'onCreateUpdate')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_UPDATE, array($this, 'onUpdate')); $this->assertTrue($tm->update(array('id' => 1, 'title' => 'Task #1'))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_CREATE_UPDATE.'.TaskModificationTest::onCreateUpdate', $called); - $this->assertArrayHasKey(Task::EVENT_UPDATE.'.TaskModificationTest::onUpdate', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.TaskModificationTest::onCreateUpdate', $called); + $this->assertArrayHasKey(TaskModel::EVENT_UPDATE.'.TaskModificationTest::onUpdate', $called); $task = $tf->getById(1); $this->assertEquals('Task #1', $task['title']); @@ -83,10 +83,10 @@ class TaskModificationTest extends Base public function testChangeAssignee() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -94,12 +94,12 @@ class TaskModificationTest extends Base $task = $tf->getById(1); $this->assertEquals(0, $task['owner_id']); - $this->container['dispatcher']->addListener(Task::EVENT_ASSIGNEE_CHANGE, array($this, 'onAssigneeChange')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_ASSIGNEE_CHANGE, array($this, 'onAssigneeChange')); $this->assertTrue($tm->update(array('id' => 1, 'owner_id' => 1))); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_ASSIGNEE_CHANGE.'.TaskModificationTest::onAssigneeChange', $called); + $this->assertArrayHasKey(TaskModel::EVENT_ASSIGNEE_CHANGE.'.TaskModificationTest::onAssigneeChange', $called); $task = $tf->getById(1); $this->assertEquals(1, $task['owner_id']); @@ -107,10 +107,10 @@ class TaskModificationTest extends Base public function testChangeDescription() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -126,10 +126,10 @@ class TaskModificationTest extends Base public function testChangeCategory() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -145,10 +145,10 @@ class TaskModificationTest extends Base public function testChangeColor() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -164,10 +164,10 @@ class TaskModificationTest extends Base public function testChangeScore() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -183,10 +183,10 @@ class TaskModificationTest extends Base public function testChangeDueDate() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -207,10 +207,10 @@ class TaskModificationTest extends Base public function testChangeStartedDate() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -245,10 +245,10 @@ class TaskModificationTest extends Base public function testChangeTimeEstimated() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -264,10 +264,10 @@ class TaskModificationTest extends Base public function testChangeTimeSpent() { - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tm = new TaskModification($this->container); - $tf = new TaskFinder($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); + $tm = new TaskModificationModel($this->container); + $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); diff --git a/tests/units/Model/TaskPositionTest.php b/tests/units/Model/TaskPositionTest.php index 0f2e4b88..7ab6950e 100644 --- a/tests/units/Model/TaskPositionTest.php +++ b/tests/units/Model/TaskPositionTest.php @@ -2,26 +2,26 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Task; -use Kanboard\Model\Column; -use Kanboard\Model\TaskStatus; -use Kanboard\Model\TaskPosition; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; -use Kanboard\Model\Swimlane; +use Kanboard\Model\TaskModel; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\TaskStatusModel; +use Kanboard\Model\TaskPositionModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\SwimlaneModel; class TaskPositionTest extends Base { public function testGetTaskProgression() { - $t = new Task($this->container); - $ts = new TaskStatus($this->container); - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $columnModel = new Column($this->container); + $t = new TaskModel($this->container); + $ts = new TaskStatusModel($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); @@ -42,10 +42,10 @@ class TaskPositionTest extends Base public function testMoveTaskToWrongPosition() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); @@ -69,10 +69,10 @@ class TaskPositionTest extends Base public function testMoveTaskToGreaterPosition() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); @@ -96,10 +96,10 @@ class TaskPositionTest extends Base public function testMoveTaskToEmptyColumn() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); @@ -123,10 +123,10 @@ class TaskPositionTest extends Base public function testMoveTaskToAnotherColumn() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); @@ -186,10 +186,10 @@ class TaskPositionTest extends Base public function testMoveTaskTop() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); @@ -224,10 +224,10 @@ class TaskPositionTest extends Base public function testMoveTaskBottom() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); @@ -262,10 +262,10 @@ class TaskPositionTest extends Base public function testMovePosition() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $counter = 1; @@ -415,11 +415,11 @@ class TaskPositionTest extends Base public function testMoveTaskSwimlane() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); @@ -522,11 +522,11 @@ class TaskPositionTest extends Base public function testEvents() { - $tp = new TaskPosition($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $tp = new TaskPositionModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); @@ -534,9 +534,9 @@ class TaskPositionTest extends Base $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' => 2))); - $this->container['dispatcher']->addListener(Task::EVENT_MOVE_COLUMN, array($this, 'onMoveColumn')); - $this->container['dispatcher']->addListener(Task::EVENT_MOVE_POSITION, array($this, 'onMovePosition')); - $this->container['dispatcher']->addListener(Task::EVENT_MOVE_SWIMLANE, array($this, 'onMoveSwimlane')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_MOVE_COLUMN, array($this, 'onMoveColumn')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_MOVE_POSITION, array($this, 'onMovePosition')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_MOVE_SWIMLANE, array($this, 'onMoveSwimlane')); // We move the task 1 to the column 2 $this->assertTrue($tp->movePosition(1, 1, 2, 1)); @@ -552,7 +552,7 @@ class TaskPositionTest extends Base $this->assertEquals(2, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_MOVE_COLUMN.'.TaskPositionTest::onMoveColumn', $called); + $this->assertArrayHasKey(TaskModel::EVENT_MOVE_COLUMN.'.TaskPositionTest::onMoveColumn', $called); $this->assertEquals(1, count($called)); // We move the task 1 to the position 2 @@ -569,7 +569,7 @@ class TaskPositionTest extends Base $this->assertEquals(1, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_MOVE_POSITION.'.TaskPositionTest::onMovePosition', $called); + $this->assertArrayHasKey(TaskModel::EVENT_MOVE_POSITION.'.TaskPositionTest::onMovePosition', $called); $this->assertEquals(2, count($called)); // Move to another swimlane @@ -588,7 +588,7 @@ class TaskPositionTest extends Base $this->assertEquals(0, $task['swimlane_id']); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_MOVE_SWIMLANE.'.TaskPositionTest::onMoveSwimlane', $called); + $this->assertArrayHasKey(TaskModel::EVENT_MOVE_SWIMLANE.'.TaskPositionTest::onMoveSwimlane', $called); $this->assertEquals(3, count($called)); } diff --git a/tests/units/Model/TaskStatusTest.php b/tests/units/Model/TaskStatusTest.php index aa48be5e..f011409d 100644 --- a/tests/units/Model/TaskStatusTest.php +++ b/tests/units/Model/TaskStatusTest.php @@ -2,23 +2,23 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Swimlane; -use Kanboard\Model\Subtask; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskStatus; -use Kanboard\Model\Project; +use Kanboard\Model\SwimlaneModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskStatusModel; +use Kanboard\Model\ProjectModel; class TaskStatusTest extends Base { public function testCloseBySwimlaneAndColumn() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $ts = new TaskStatus($this->container); - $p = new Project($this->container); - $s = new Swimlane($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $ts = new TaskStatusModel($this->container); + $p = new ProjectModel($this->container); + $s = new SwimlaneModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $s->create(array('name' => 'test', 'project_id' => 1))); @@ -56,10 +56,10 @@ class TaskStatusTest extends Base public function testStatus() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $ts = new TaskStatus($this->container); - $p = new Project($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $ts = new TaskStatusModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -70,21 +70,21 @@ class TaskStatusTest extends Base $task = $tf->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); + $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification'], '', 1); // We close the task - $this->container['dispatcher']->addListener(Task::EVENT_CLOSE, array($this, 'onTaskClose')); - $this->container['dispatcher']->addListener(Task::EVENT_OPEN, array($this, 'onTaskOpen')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CLOSE, array($this, 'onTaskClose')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_OPEN, array($this, 'onTaskOpen')); $this->assertTrue($ts->close(1)); $this->assertTrue($ts->isClosed(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(Task::STATUS_CLOSED, $task['is_active']); + $this->assertEquals(TaskModel::STATUS_CLOSED, $task['is_active']); $this->assertEquals(time(), $task['date_completed'], 'Bad completion timestamp', 1); $this->assertEquals(time(), $task['date_modification'], 'Bad modification timestamp', 1); @@ -95,7 +95,7 @@ class TaskStatusTest extends Base $task = $tf->getById(1); $this->assertNotEmpty($task); - $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); + $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']); $this->assertEquals(0, $task['date_completed']); $this->assertEquals(time(), $task['date_modification'], '', 1); @@ -120,10 +120,10 @@ class TaskStatusTest extends Base public function testThatAllSubtasksAreClosed() { - $ts = new TaskStatus($this->container); - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $p = new Project($this->container); + $ts = new TaskStatusModel($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); @@ -137,7 +137,7 @@ class TaskStatusTest extends Base $this->assertNotEmpty($subtasks); foreach ($subtasks as $subtask) { - $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']); + $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']); } } } diff --git a/tests/units/Model/TaskTest.php b/tests/units/Model/TaskTest.php index e9815b83..89fc4dc1 100644 --- a/tests/units/Model/TaskTest.php +++ b/tests/units/Model/TaskTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; class TaskTest extends Base { public function testRemove() { - $t = new Task($this->container); - $tc = new TaskCreation($this->container); - $p = new Project($this->container); + $t = new TaskModel($this->container); + $tc = new TaskCreationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); @@ -23,36 +23,36 @@ class TaskTest extends Base public function testGetTaskIdFromText() { - $t = new Task($this->container); + $t = new TaskModel($this->container); $this->assertEquals(123, $t->getTaskIdFromText('My task #123')); $this->assertEquals(0, $t->getTaskIdFromText('My task 123')); } public function testRecurrenceSettings() { - $t = new Task($this->container); + $t = new TaskModel($this->container); $statuses = $t->getRecurrenceStatusList(); $this->assertCount(2, $statuses); - $this->assertArrayHasKey(Task::RECURRING_STATUS_NONE, $statuses); - $this->assertArrayHasKey(Task::RECURRING_STATUS_PENDING, $statuses); - $this->assertArrayNotHasKey(Task::RECURRING_STATUS_PROCESSED, $statuses); + $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_NONE, $statuses); + $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_PENDING, $statuses); + $this->assertArrayNotHasKey(TaskModel::RECURRING_STATUS_PROCESSED, $statuses); $triggers = $t->getRecurrenceTriggerList(); $this->assertCount(3, $triggers); - $this->assertArrayHasKey(Task::RECURRING_TRIGGER_FIRST_COLUMN, $triggers); - $this->assertArrayHasKey(Task::RECURRING_TRIGGER_LAST_COLUMN, $triggers); - $this->assertArrayHasKey(Task::RECURRING_TRIGGER_CLOSE, $triggers); + $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_FIRST_COLUMN, $triggers); + $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_LAST_COLUMN, $triggers); + $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_CLOSE, $triggers); $dates = $t->getRecurrenceBasedateList(); $this->assertCount(2, $dates); - $this->assertArrayHasKey(Task::RECURRING_BASEDATE_DUEDATE, $dates); - $this->assertArrayHasKey(Task::RECURRING_BASEDATE_TRIGGERDATE, $dates); + $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_DUEDATE, $dates); + $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_TRIGGERDATE, $dates); $timeframes = $t->getRecurrenceTimeframeList(); $this->assertCount(3, $timeframes); - $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_DAYS, $timeframes); - $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_MONTHS, $timeframes); - $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_YEARS, $timeframes); + $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_DAYS, $timeframes); + $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_MONTHS, $timeframes); + $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_YEARS, $timeframes); } } diff --git a/tests/units/Model/TimezoneTest.php b/tests/units/Model/TimezoneTest.php index ac2cd6a1..8e7103d8 100644 --- a/tests/units/Model/TimezoneTest.php +++ b/tests/units/Model/TimezoneTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Timezone; +use Kanboard\Model\TimezoneModel; class TimezoneTest extends Base { public function testGetTimezones() { - $timezoneModel = new Timezone($this->container); + $timezoneModel = new TimezoneModel($this->container); $this->assertNotEmpty($timezoneModel->getTimezones()); $this->assertArrayHasKey('Europe/Paris', $timezoneModel->getTimezones()); $this->assertContains('Europe/Paris', $timezoneModel->getTimezones()); @@ -20,7 +20,7 @@ class TimezoneTest extends Base public function testGetCurrentTimezone() { - $timezoneModel = new Timezone($this->container); + $timezoneModel = new TimezoneModel($this->container); $this->assertEquals('UTC', $timezoneModel->getCurrentTimezone()); $this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris'); diff --git a/tests/units/Model/TransitionTest.php b/tests/units/Model/TransitionTest.php index 0c262e78..2edf9c43 100644 --- a/tests/units/Model/TransitionTest.php +++ b/tests/units/Model/TransitionTest.php @@ -2,17 +2,17 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Transition; -use Kanboard\Model\Project; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TransitionModel; +use Kanboard\Model\ProjectModel; class TransitionTest extends Base { public function testSave() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $transitionModel = new Transition($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $transitionModel = new TransitionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -40,9 +40,9 @@ class TransitionTest extends Base public function testGetTimeSpentByTask() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $transitionModel = new Transition($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $transitionModel = new TransitionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); @@ -77,9 +77,9 @@ class TransitionTest extends Base public function testGetAllByProject() { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $transitionModel = new Transition($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $transitionModel = new TransitionModel($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test1'))); diff --git a/tests/units/Model/UserLockingTest.php b/tests/units/Model/UserLockingTest.php index c743f8eb..1fcb97fe 100644 --- a/tests/units/Model/UserLockingTest.php +++ b/tests/units/Model/UserLockingTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\UserLocking; +use Kanboard\Model\UserLockingModel; class UserLockingTest extends Base { public function testFailedLogin() { - $u = new UserLocking($this->container); + $u = new UserLockingModel($this->container); $this->assertEquals(0, $u->getFailedLogin('admin')); $this->assertEquals(0, $u->getFailedLogin('not_found')); @@ -23,7 +23,7 @@ class UserLockingTest extends Base public function testLocking() { - $u = new UserLocking($this->container); + $u = new UserLockingModel($this->container); $this->assertFalse($u->isLocked('admin')); $this->assertFalse($u->isLocked('not_found')); @@ -33,7 +33,7 @@ class UserLockingTest extends Base public function testCaptcha() { - $u = new UserLocking($this->container); + $u = new UserLockingModel($this->container); $this->assertTrue($u->incrementFailedLogin('admin')); $this->assertFalse($u->hasCaptcha('admin', 2)); diff --git a/tests/units/Model/UserMentionTest.php b/tests/units/Model/UserMentionTest.php index d50c9285..b41c92cd 100644 --- a/tests/units/Model/UserMentionTest.php +++ b/tests/units/Model/UserMentionTest.php @@ -4,19 +4,19 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Core\Security\Role; use Kanboard\Event\GenericEvent; -use Kanboard\Model\User; -use Kanboard\Model\Task; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\UserMention; +use Kanboard\Model\UserModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\UserMentionModel; class UserMentionTest extends Base { public function testGetMentionedUsersWithNoMentions() { - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $this->assertNotFalse($userModel->create(array('username' => 'user1'))); $this->assertEmpty($userMentionModel->getMentionedUsers('test')); @@ -24,8 +24,8 @@ class UserMentionTest extends Base public function testGetMentionedUsersWithNotficationDisabled() { - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $this->assertNotFalse($userModel->create(array('username' => 'user1'))); $this->assertEmpty($userMentionModel->getMentionedUsers('test @user1')); @@ -33,8 +33,8 @@ class UserMentionTest extends Base public function testGetMentionedUsersWithNotficationEnabled() { - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $this->assertNotFalse($userModel->create(array('username' => 'user1'))); $this->assertNotFalse($userModel->create(array('username' => 'user2', 'name' => 'Foobar', 'notifications_enabled' => 1))); @@ -50,8 +50,8 @@ class UserMentionTest extends Base public function testGetMentionedUsersWithNotficationEnabledAndUserLoggedIn() { $this->container['sessionStorage']->user = array('id' => 3); - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $this->assertNotFalse($userModel->create(array('username' => 'user1'))); $this->assertNotFalse($userModel->create(array('username' => 'user2', 'name' => 'Foobar', 'notifications_enabled' => 1))); @@ -61,10 +61,10 @@ class UserMentionTest extends Base public function testFireEventsWithMultipleMentions() { - $projectUserRoleModel = new ProjectUserRole($this->container); - $projectModel = new Project($this->container); - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $event = new GenericEvent(array('project_id' => 1)); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User 1', 'notifications_enabled' => 1))); @@ -73,21 +73,21 @@ class UserMentionTest extends Base $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); $this->assertTrue($projectUserRoleModel->addUser(1, 3, Role::PROJECT_MEMBER)); - $this->container['dispatcher']->addListener(Task::EVENT_USER_MENTION, array($this, 'onUserMention')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_USER_MENTION, array($this, 'onUserMention')); - $userMentionModel->fireEvents('test @user1 @user2', Task::EVENT_USER_MENTION, $event); + $userMentionModel->fireEvents('test @user1 @user2', TaskModel::EVENT_USER_MENTION, $event); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_USER_MENTION.'.UserMentionTest::onUserMention', $called); + $this->assertArrayHasKey(TaskModel::EVENT_USER_MENTION.'.UserMentionTest::onUserMention', $called); } public function testFireEventsWithNoProjectId() { - $projectUserRoleModel = new ProjectUserRole($this->container); - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $userModel = new User($this->container); - $userMentionModel = new UserMention($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $userModel = new UserModel($this->container); + $userMentionModel = new UserMentionModel($this->container); $event = new GenericEvent(array('task_id' => 1)); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User 1', 'notifications_enabled' => 1))); @@ -98,12 +98,12 @@ class UserMentionTest extends Base $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'Task 1'))); - $this->container['dispatcher']->addListener(Task::EVENT_USER_MENTION, array($this, 'onUserMention')); + $this->container['dispatcher']->addListener(TaskModel::EVENT_USER_MENTION, array($this, 'onUserMention')); - $userMentionModel->fireEvents('test @user1 @user2', Task::EVENT_USER_MENTION, $event); + $userMentionModel->fireEvents('test @user1 @user2', TaskModel::EVENT_USER_MENTION, $event); $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(Task::EVENT_USER_MENTION.'.UserMentionTest::onUserMention', $called); + $this->assertArrayHasKey(TaskModel::EVENT_USER_MENTION.'.UserMentionTest::onUserMention', $called); } public function onUserMention($event) diff --git a/tests/units/Model/UserMetadataTest.php b/tests/units/Model/UserMetadataTest.php index 457f1fb2..fb427371 100644 --- a/tests/units/Model/UserMetadataTest.php +++ b/tests/units/Model/UserMetadataTest.php @@ -2,15 +2,15 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\User; -use Kanboard\Model\UserMetadata; +use Kanboard\Model\UserModel; +use Kanboard\Model\UserMetadataModel; class UserMetadataTest extends Base { public function testOperations() { - $m = new UserMetadata($this->container); - $u = new User($this->container); + $m = new UserMetadataModel($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'foobar'))); diff --git a/tests/units/Model/UserNotificationFilterTest.php b/tests/units/Model/UserNotificationFilterTest.php index 73c7d905..49c7aa0a 100644 --- a/tests/units/Model/UserNotificationFilterTest.php +++ b/tests/units/Model/UserNotificationFilterTest.php @@ -2,27 +2,27 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\User; -use Kanboard\Model\Project; -use Kanboard\Model\UserNotificationFilter; -use Kanboard\Model\UserNotification; +use Kanboard\Model\UserModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserNotificationFilterModel; +use Kanboard\Model\UserNotificationModel; class UserNotificationFilterTest extends Base { public function testGetFilters() { - $nf = new UserNotificationFilter($this->container); + $nf = new UserNotificationFilterModel($this->container); $filters = $nf->getFilters(); - $this->assertArrayHasKey(UserNotificationFilter::FILTER_NONE, $filters); - $this->assertArrayHasKey(UserNotificationFilter::FILTER_BOTH, $filters); - $this->assertArrayHasKey(UserNotificationFilter::FILTER_CREATOR, $filters); - $this->assertArrayHasKey(UserNotificationFilter::FILTER_ASSIGNEE, $filters); + $this->assertArrayHasKey(UserNotificationFilterModel::FILTER_NONE, $filters); + $this->assertArrayHasKey(UserNotificationFilterModel::FILTER_BOTH, $filters); + $this->assertArrayHasKey(UserNotificationFilterModel::FILTER_CREATOR, $filters); + $this->assertArrayHasKey(UserNotificationFilterModel::FILTER_ASSIGNEE, $filters); } public function testSaveProjectFilter() { - $nf = new UserNotificationFilter($this->container); - $p = new Project($this->container); + $nf = new UserNotificationFilterModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); @@ -35,78 +35,78 @@ class UserNotificationFilterTest extends Base public function testSaveUserFilter() { - $nf = new UserNotificationFilter($this->container); + $nf = new UserNotificationFilterModel($this->container); - $this->assertEquals(UserNotificationFilter::FILTER_BOTH, $nf->getSelectedFilter(1)); - $nf->saveFilter(1, UserNotificationFilter::FILTER_CREATOR); - $this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $nf->getSelectedFilter(1)); + $this->assertEquals(UserNotificationFilterModel::FILTER_BOTH, $nf->getSelectedFilter(1)); + $nf->saveFilter(1, UserNotificationFilterModel::FILTER_CREATOR); + $this->assertEquals(UserNotificationFilterModel::FILTER_CREATOR, $nf->getSelectedFilter(1)); } public function testFilterNone() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $this->assertTrue($n->filterNone($u->getById(2))); - $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH))); + $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_BOTH))); $this->assertFalse($n->filterNone($u->getById(3))); } public function testFilterCreator() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR))); + $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilterModel::FILTER_CREATOR))); $this->assertTrue($n->filterCreator($u->getById(2), array('task' => array('creator_id' => 2)))); - $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR))); + $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_CREATOR))); $this->assertFalse($n->filterCreator($u->getById(3), array('task' => array('creator_id' => 1)))); - $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $this->assertFalse($n->filterCreator($u->getById(4), array('task' => array('creator_id' => 2)))); } public function testFilterAssignee() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE))); + $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilterModel::FILTER_ASSIGNEE))); $this->assertTrue($n->filterAssignee($u->getById(2), array('task' => array('owner_id' => 2)))); - $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE))); + $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_ASSIGNEE))); $this->assertFalse($n->filterAssignee($u->getById(3), array('task' => array('owner_id' => 1)))); - $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $this->assertFalse($n->filterAssignee($u->getById(4), array('task' => array('owner_id' => 2)))); } public function testFilterBoth() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH))); + $this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilterModel::FILTER_BOTH))); $this->assertTrue($n->filterBoth($u->getById(2), array('task' => array('owner_id' => 2, 'creator_id' => 1)))); $this->assertTrue($n->filterBoth($u->getById(2), array('task' => array('owner_id' => 0, 'creator_id' => 2)))); - $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH))); + $this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_BOTH))); $this->assertFalse($n->filterBoth($u->getById(3), array('task' => array('owner_id' => 1, 'creator_id' => 1)))); $this->assertFalse($n->filterBoth($u->getById(3), array('task' => array('owner_id' => 2, 'creator_id' => 1)))); - $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $this->assertFalse($n->filterBoth($u->getById(4), array('task' => array('owner_id' => 2, 'creator_id' => 1)))); } public function testFilterProject() { - $u = new User($this->container); - $n = new UserNotification($this->container); - $nf = new UserNotificationFilter($this->container); - $p = new Project($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationModel($this->container); + $nf = new UserNotificationFilterModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); @@ -115,7 +115,7 @@ class UserNotificationFilterTest extends Base $this->assertTrue($nf->filterProject($u->getById(1), array())); // User that select only some projects - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $n->saveSettings(2, array('notifications_enabled' => 1, 'notification_projects' => array(2 => true))); $this->assertFalse($nf->filterProject($u->getById(2), array('task' => array('project_id' => 1)))); @@ -124,20 +124,20 @@ class UserNotificationFilterTest extends Base public function testFilterUserWithNoFilter() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_NONE))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE))); $this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1)))); } public function testFilterUserWithAssigneeFilter() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_ASSIGNEE))); $this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'owner_id' => 2)))); $this->assertFalse($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'owner_id' => 1)))); @@ -145,10 +145,10 @@ class UserNotificationFilterTest extends Base public function testFilterUserWithCreatorFilter() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_CREATOR))); $this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 2)))); $this->assertFalse($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 1)))); @@ -156,10 +156,10 @@ class UserNotificationFilterTest extends Base public function testFilterUserWithBothFilter() { - $u = new User($this->container); - $n = new UserNotificationFilter($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationFilterModel($this->container); - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_BOTH))); $this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 2, 'owner_id' => 3)))); $this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 0, 'owner_id' => 2)))); @@ -169,15 +169,15 @@ class UserNotificationFilterTest extends Base public function testFilterUserWithBothFilterAndProjectSelected() { - $u = new User($this->container); - $n = new UserNotification($this->container); - $nf = new UserNotificationFilter($this->container); - $p = new Project($this->container); + $u = new UserModel($this->container); + $n = new UserNotificationModel($this->container); + $nf = new UserNotificationFilterModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); - $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH))); + $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilterModel::FILTER_BOTH))); $n->saveSettings(2, array('notifications_enabled' => 1, 'notification_projects' => array(2 => true))); diff --git a/tests/units/Model/UserNotificationTest.php b/tests/units/Model/UserNotificationTest.php index a15fe226..6ee5c875 100644 --- a/tests/units/Model/UserNotificationTest.php +++ b/tests/units/Model/UserNotificationTest.php @@ -2,28 +2,28 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\User; -use Kanboard\Model\Group; -use Kanboard\Model\GroupMember; -use Kanboard\Model\Project; -use Kanboard\Model\ProjectPermission; -use Kanboard\Model\Task; -use Kanboard\Model\ProjectUserRole; -use Kanboard\Model\ProjectGroupRole; -use Kanboard\Model\UserNotification; -use Kanboard\Model\UserNotificationFilter; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\GroupModel; +use Kanboard\Model\GroupMemberModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\ProjectPermissionModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\ProjectUserRoleModel; +use Kanboard\Model\ProjectGroupRoleModel; +use Kanboard\Model\UserNotificationModel; +use Kanboard\Model\UserNotificationFilterModel; use Kanboard\Core\Security\Role; class UserNotificationTest extends Base { public function testEnableDisableNotification() { - $u = new User($this->container); - $p = new Project($this->container); - $n = new UserNotification($this->container); - $pp = new ProjectUserRole($this->container); + $u = new UserModel($this->container); + $p = new ProjectModel($this->container); + $n = new UserNotificationModel($this->container); + $pp = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $this->assertEquals(2, $u->create(array('username' => 'user1'))); @@ -38,29 +38,29 @@ class UserNotificationTest extends Base public function testReadWriteSettings() { - $n = new UserNotification($this->container); - $p = new Project($this->container); + $n = new UserNotificationModel($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $n->saveSettings(1, array( 'notifications_enabled' => 1, - 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR, + 'notifications_filter' => UserNotificationFilterModel::FILTER_CREATOR, 'notification_types' => array('email' => 1), 'notification_projects' => array(), )); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(0)) ->method('getSelectedTypes') ->will($this->returnValue(array('email'))); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(1)) ->method('getSelectedTypes') ->will($this->returnValue(array('email'))); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(2)) ->method('getSelectedTypes') ->with($this->equalTo(1)) @@ -69,7 +69,7 @@ class UserNotificationTest extends Base $settings = $n->readSettings(1); $this->assertNotEmpty($settings); $this->assertEquals(1, $settings['notifications_enabled']); - $this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $settings['notifications_filter']); + $this->assertEquals(UserNotificationFilterModel::FILTER_CREATOR, $settings['notifications_filter']); $this->assertEquals(array('email'), $settings['notification_types']); $this->assertEmpty($settings['notification_projects']); @@ -83,7 +83,7 @@ class UserNotificationTest extends Base $n->saveSettings(1, array( 'notifications_enabled' => 1, - 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE, + 'notifications_filter' => UserNotificationFilterModel::FILTER_ASSIGNEE, 'notification_types' => array('web' => 1, 'email' => 1), 'notification_projects' => array(1 => 1), )); @@ -91,20 +91,20 @@ class UserNotificationTest extends Base $settings = $n->readSettings(1); $this->assertNotEmpty($settings); $this->assertEquals(1, $settings['notifications_enabled']); - $this->assertEquals(UserNotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']); + $this->assertEquals(UserNotificationFilterModel::FILTER_ASSIGNEE, $settings['notifications_filter']); $this->assertEquals(array('email', 'web'), $settings['notification_types']); $this->assertEquals(array(1), $settings['notification_projects']); } public function testGetGroupMembersWithNotificationEnabled() { - $userModel = new User($this->container); - $groupModel = new Group($this->container); - $groupMemberModel = new GroupMember($this->container); - $projectModel = new Project($this->container); - $userNotificationModel = new UserNotification($this->container); - $projectGroupRole = new ProjectGroupRole($this->container); - $projectUserRole = new ProjectUserRole($this->container); + $userModel = new UserModel($this->container); + $groupModel = new GroupModel($this->container); + $groupMemberModel = new GroupMemberModel($this->container); + $projectModel = new ProjectModel($this->container); + $userNotificationModel = new UserNotificationModel($this->container); + $projectGroupRole = new ProjectGroupRoleModel($this->container); + $projectUserRole = new ProjectUserRoleModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1))); $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1))); @@ -136,10 +136,10 @@ class UserNotificationTest extends Base public function testGetProjectMembersWithNotifications() { - $u = new User($this->container); - $p = new Project($this->container); - $n = new UserNotification($this->container); - $pp = new ProjectUserRole($this->container); + $u = new UserModel($this->container); + $p = new ProjectModel($this->container); + $n = new UserNotificationModel($this->container); + $pp = new ProjectUserRoleModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); @@ -181,10 +181,10 @@ class UserNotificationTest extends Base public function testGetUsersWithNotificationsWhenEverybodyAllowed() { - $u = new User($this->container); - $p = new Project($this->container); - $n = new UserNotification($this->container); - $pp = new ProjectPermission($this->container); + $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)); @@ -215,12 +215,12 @@ class UserNotificationTest extends Base public function testSendNotifications() { - $u = new User($this->container); - $n = new UserNotification($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $pp = new ProjectPermission($this->container); + $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); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -229,7 +229,7 @@ class UserNotificationTest extends Base $n->saveSettings(1, array( 'notifications_enabled' => 1, - 'notifications_filter' => UserNotificationFilter::FILTER_NONE, + 'notifications_filter' => UserNotificationFilterModel::FILTER_NONE, 'notification_types' => array('web' => 1, 'email' => 1), )); @@ -242,23 +242,23 @@ class UserNotificationTest extends Base ->expects($this->exactly(2)) ->method('notifyUser'); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(0)) ->method('getSelectedTypes') ->will($this->returnValue(array('email', 'web'))); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(1)) ->method('getType') ->with($this->equalTo('email')) ->will($this->returnValue($notifier)); - $this->container['userNotificationType'] + $this->container['userNotificationTypeModel'] ->expects($this->at(2)) ->method('getType') ->with($this->equalTo('web')) ->will($this->returnValue($notifier)); - $n->sendNotifications(Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $n->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); } } diff --git a/tests/units/Model/UserNotificationTypeTest.php b/tests/units/Model/UserNotificationTypeTest.php index da22afef..29223c18 100644 --- a/tests/units/Model/UserNotificationTypeTest.php +++ b/tests/units/Model/UserNotificationTypeTest.php @@ -2,13 +2,13 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\UserNotificationType; +use Kanboard\Model\UserNotificationTypeModel; class UserNotificationTypeTest extends Base { public function testGetTypes() { - $nt = new UserNotificationType($this->container); + $nt = new UserNotificationTypeModel($this->container); $this->assertEmpty($nt->getTypes()); $nt->setType('email', 'Email', 'Something'); @@ -18,7 +18,7 @@ class UserNotificationTypeTest extends Base public function testGetSelectedTypes() { - $nt = new UserNotificationType($this->container); + $nt = new UserNotificationTypeModel($this->container); // No type defined $this->assertEmpty($nt->getSelectedTypes(1)); diff --git a/tests/units/Model/UserTest.php b/tests/units/Model/UserTest.php index b53acb7d..0be6172e 100644 --- a/tests/units/Model/UserTest.php +++ b/tests/units/Model/UserTest.php @@ -2,19 +2,19 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\User; -use Kanboard\Model\Subtask; -use Kanboard\Model\Comment; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\Project; +use Kanboard\Model\UserModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\CommentModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\ProjectModel; use Kanboard\Core\Security\Role; class UserTest extends Base { public function testGetByEmail() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1', 'password' => '123456', 'email' => 'user1@localhost'))); $this->assertNotFalse($u->create(array('username' => 'user2', 'password' => '123456', 'email' => ''))); @@ -24,20 +24,20 @@ class UserTest extends Base public function testGetByExternalId() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1', 'password' => '123456', 'gitlab_id' => '1234'))); $this->assertNotEmpty($u->getByExternalId('gitlab_id', '1234')); $this->assertEmpty($u->getByExternalId('gitlab_id', '')); - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user2', 'password' => '123456', 'github_id' => 'plop'))); $this->assertNotFalse($u->create(array('username' => 'user3', 'password' => '123456', 'github_id' => ''))); $this->assertNotEmpty($u->getByExternalId('github_id', 'plop')); $this->assertEmpty($u->getByExternalId('github_id', '')); - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user4', 'password' => '123456', 'google_id' => '1234'))); $this->assertNotFalse($u->create(array('username' => 'user5', 'password' => '123456', 'google_id' => ''))); @@ -47,7 +47,7 @@ class UserTest extends Base public function testGetByToken() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1', 'token' => 'random'))); $this->assertNotFalse($u->create(array('username' => 'user2', 'token' => ''))); @@ -57,7 +57,7 @@ class UserTest extends Base public function testGetByUsername() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1'))); $this->assertNotEmpty($u->getByUsername('user1')); @@ -67,7 +67,7 @@ class UserTest extends Base public function testExists() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1'))); $this->assertTrue($u->exists(1)); @@ -77,14 +77,14 @@ class UserTest extends Base public function testCount() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'user1'))); $this->assertEquals(2, $u->count()); } public function testGetAll() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'you'))); $this->assertEquals(3, $u->create(array('username' => 'me', 'name' => 'Me'))); @@ -97,7 +97,7 @@ class UserTest extends Base public function testGetActiveUsersList() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'you'))); $this->assertEquals(3, $u->create(array('username' => 'me', 'name' => 'Me too'))); $this->assertEquals(4, $u->create(array('username' => 'foobar', 'is_active' => 0))); @@ -115,10 +115,10 @@ class UserTest extends Base $users = $u->getActiveUsersList(true); $expected = array( - User::EVERYBODY_ID => 'Everybody', - 1 => 'admin', - 3 => 'Me too', - 2 => 'you', + UserModel::EVERYBODY_ID => 'Everybody', + 1 => 'admin', + 3 => 'Me too', + 2 => 'you', ); $this->assertEquals($expected, $users); @@ -126,7 +126,7 @@ class UserTest extends Base public function testGetFullname() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user1'))); $this->assertEquals(3, $u->create(array('username' => 'user2', 'name' => 'User #2'))); @@ -142,7 +142,7 @@ class UserTest extends Base public function testIsAdmin() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user1'))); $this->assertTrue($u->isAdmin(1)); @@ -160,7 +160,7 @@ class UserTest extends Base public function testPrepare() { - $u = new User($this->container); + $u = new UserModel($this->container); $input = array( 'username' => 'user1', @@ -237,7 +237,7 @@ class UserTest extends Base public function testCreate() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'user #1', 'password' => '123456', 'name' => 'User'))); $this->assertEquals(3, $u->create(array('username' => 'user #2', 'is_ldap_user' => 1))); $this->assertEquals(4, $u->create(array('username' => 'user #3', 'role' => Role::APP_MANAGER))); @@ -280,7 +280,7 @@ class UserTest extends Base public function testUpdate() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertEquals(2, $u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto'))); $this->assertEquals(3, $u->create(array('username' => 'plop', 'gitlab_id' => '123'))); @@ -300,12 +300,12 @@ class UserTest extends Base public function testRemove() { - $u = new User($this->container); - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $s = new Subtask($this->container); - $c = new Comment($this->container); + $u = new UserModel($this->container); + $tc = new TaskCreationModel($this->container); + $tf = new TaskFinderModel($this->container); + $p = new ProjectModel($this->container); + $s = new SubtaskModel($this->container); + $c = new CommentModel($this->container); $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto'))); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); @@ -355,7 +355,7 @@ class UserTest extends Base public function testEnableDisablePublicAccess() { - $u = new User($this->container); + $u = new UserModel($this->container); $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456'))); $user = $u->getById(2); @@ -380,7 +380,7 @@ class UserTest extends Base public function testEnableDisable() { - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'toto'))); $this->assertTrue($userModel->isActive(2)); diff --git a/tests/units/Model/UserUnreadNotificationTest.php b/tests/units/Model/UserUnreadNotificationTest.php index eb162a40..e6716e6c 100644 --- a/tests/units/Model/UserUnreadNotificationTest.php +++ b/tests/units/Model/UserUnreadNotificationTest.php @@ -2,42 +2,42 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Task; -use Kanboard\Model\Project; -use Kanboard\Model\UserUnreadNotification; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\TaskModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\UserUnreadNotificationModel; class UserUnreadNotificationTest extends Base { public function testHasNotification() { - $wn = new UserUnreadNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); + $wn = new UserUnreadNotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); $this->assertFalse($wn->hasNotifications(1)); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); $this->assertTrue($wn->hasNotifications(1)); } public function testMarkAllAsRead() { - $wn = new UserUnreadNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); + $wn = new UserUnreadNotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); $this->assertTrue($wn->hasNotifications(1)); $this->assertTrue($wn->markAllAsRead(1)); @@ -48,15 +48,15 @@ class UserUnreadNotificationTest extends Base public function testMarkAsRead() { - $wn = new UserUnreadNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); + $wn = new UserUnreadNotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); $this->assertTrue($wn->hasNotifications(1)); @@ -69,16 +69,16 @@ class UserUnreadNotificationTest extends Base public function testGetAll() { - $wn = new UserUnreadNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); + $wn = new UserUnreadNotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); $this->assertEmpty($wn->getAll(2)); @@ -90,16 +90,16 @@ class UserUnreadNotificationTest extends Base public function testGetOne() { - $wn = new UserUnreadNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); + $wn = new UserUnreadNotificationModel($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); - $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $wn->create(1, TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); $this->assertEmpty($wn->getAll(2)); diff --git a/tests/units/Notification/MailTest.php b/tests/units/Notification/MailTest.php index 8d32b497..9f077ac8 100644 --- a/tests/units/Notification/MailTest.php +++ b/tests/units/Notification/MailTest.php @@ -2,14 +2,14 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\TaskFinder; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Subtask; -use Kanboard\Model\Comment; -use Kanboard\Model\User; -use Kanboard\Model\TaskFile; -use Kanboard\Model\Project; -use Kanboard\Model\Task; +use Kanboard\Model\TaskFinderModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\SubtaskModel; +use Kanboard\Model\CommentModel; +use Kanboard\Model\UserModel; +use Kanboard\Model\TaskFileModel; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; use Kanboard\Notification\MailNotification; use Kanboard\Subscriber\NotificationSubscriber; @@ -18,12 +18,12 @@ class MailTest extends Base public function testGetMailContent() { $en = new MailNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); - $s = new Subtask($this->container); - $c = new Comment($this->container); - $f = new TaskFile($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); + $s = new SubtaskModel($this->container); + $c = new CommentModel($this->container); + $f = new TaskFileModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -63,10 +63,10 @@ class MailTest extends Base public function testSendWithEmailAddress() { $en = new MailNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); - $u = new User($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); + $u = new UserModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -88,16 +88,16 @@ class MailTest extends Base $this->stringContains('test') ); - $en->notifyUser($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $en->notifyUser($u->getById(1), TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); } public function testSendWithoutEmailAddress() { $en = new MailNotification($this->container); - $p = new Project($this->container); - $tf = new TaskFinder($this->container); - $tc = new TaskCreation($this->container); - $u = new User($this->container); + $p = new ProjectModel($this->container); + $tf = new TaskFinderModel($this->container); + $tc = new TaskCreationModel($this->container); + $u = new UserModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -112,6 +112,6 @@ class MailTest extends Base ->expects($this->never()) ->method('send'); - $en->notifyUser($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $en->notifyUser($u->getById(1), TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1))); } } diff --git a/tests/units/Notification/WebhookTest.php b/tests/units/Notification/WebhookTest.php index 5984f303..5a9eb1c7 100644 --- a/tests/units/Notification/WebhookTest.php +++ b/tests/units/Notification/WebhookTest.php @@ -2,18 +2,18 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Config; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\ConfigModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; use Kanboard\Subscriber\NotificationSubscriber; class WebhookTest extends Base { public function testTaskCreation() { - $c = new Config($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $c = new ConfigModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container)); $c->save(array('webhook_url' => 'http://localhost/?task-creation')); diff --git a/tests/units/Subscriber/LdapUserPhotoSubscriberTest.php b/tests/units/Subscriber/LdapUserPhotoSubscriberTest.php index df44d232..41f40844 100644 --- a/tests/units/Subscriber/LdapUserPhotoSubscriberTest.php +++ b/tests/units/Subscriber/LdapUserPhotoSubscriberTest.php @@ -2,7 +2,7 @@ use Kanboard\Core\Security\Role; use Kanboard\Event\UserProfileSyncEvent; -use Kanboard\Model\User; +use Kanboard\Model\UserModel; use Kanboard\Subscriber\LdapUserPhotoSubscriber; use Kanboard\User\DatabaseUserProvider; use Kanboard\User\LdapUserProvider; @@ -15,7 +15,7 @@ class LdapUserPhotoSubscriberTest extends Base { $userProvider = new DatabaseUserProvider(array()); $subscriber = new LdapUserPhotoSubscriber($this->container); - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $userModel->update(array('id' => 1, 'avatar_path' => 'my avatar')); $user = $userModel->getById(1); @@ -30,7 +30,7 @@ class LdapUserPhotoSubscriberTest extends Base { $userProvider = new LdapUserProvider('dn', 'admin', 'Admin', 'admin@localhost', Role::APP_ADMIN, array(), 'my photo'); $subscriber = new LdapUserPhotoSubscriber($this->container); - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $user = $userModel->getById(1); $this->container['objectStorage'] @@ -49,7 +49,7 @@ class LdapUserPhotoSubscriberTest extends Base { $userProvider = new LdapUserProvider('dn', 'admin', 'Admin', 'admin@localhost', Role::APP_ADMIN, array()); $subscriber = new LdapUserPhotoSubscriber($this->container); - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $user = $userModel->getById(1); $this->container['objectStorage'] @@ -66,7 +66,7 @@ class LdapUserPhotoSubscriberTest extends Base { $userProvider = new LdapUserProvider('dn', 'admin', 'Admin', 'admin@localhost', Role::APP_ADMIN, array(), 'my photo'); $subscriber = new LdapUserPhotoSubscriber($this->container); - $userModel = new User($this->container); + $userModel = new UserModel($this->container); $userModel->update(array('id' => 1, 'avatar_path' => 'my avatar')); $user = $userModel->getById(1); diff --git a/tests/units/Validator/ProjectValidatorTest.php b/tests/units/Validator/ProjectValidatorTest.php index a73e8247..07de6c25 100644 --- a/tests/units/Validator/ProjectValidatorTest.php +++ b/tests/units/Validator/ProjectValidatorTest.php @@ -3,14 +3,14 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Validator\ProjectValidator; -use Kanboard\Model\Project; +use Kanboard\Model\ProjectModel; class ProjectValidatorTest extends Base { public function testValidateCreation() { $validator = new ProjectValidator($this->container); - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); @@ -39,7 +39,7 @@ class ProjectValidatorTest extends Base public function testValidateModification() { $validator = new ProjectValidator($this->container); - $p = new Project($this->container); + $p = new ProjectModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2', 'identifier' => 'TEST2'))); diff --git a/tests/units/Validator/TaskLinkValidatorTest.php b/tests/units/Validator/TaskLinkValidatorTest.php index 5ac4588e..5fc50e3e 100644 --- a/tests/units/Validator/TaskLinkValidatorTest.php +++ b/tests/units/Validator/TaskLinkValidatorTest.php @@ -3,18 +3,18 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Validator\TaskLinkValidator; -use Kanboard\Model\TaskLink; -use Kanboard\Model\TaskCreation; -use Kanboard\Model\Project; +use Kanboard\Model\TaskLinkModel; +use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\ProjectModel; class TaskLinkValidatorTest extends Base { public function testValidateCreation() { $validator = new TaskLinkValidator($this->container); - $tl = new TaskLink($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $tl = new TaskLinkModel($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); @@ -46,8 +46,8 @@ class TaskLinkValidatorTest extends Base public function testValidateModification() { $validator = new TaskLinkValidator($this->container); - $p = new Project($this->container); - $tc = new TaskCreation($this->container); + $p = new ProjectModel($this->container); + $tc = new TaskCreationModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A'))); |