Fix a couple of bugs in PR #2424
This commit is contained in:
parent
141939b703
commit
397988dd8d
|
|
@ -66,7 +66,15 @@ class ColumnController extends BaseController
|
|||
list($valid, $errors) = $this->columnValidator->validateCreation($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->columnModel->create($project['id'], $values['title'], $values['task_limit'], $values['description'], $values['hide_in_dashboard']) !== false) {
|
||||
$result = $this->columnModel->create(
|
||||
$project['id'],
|
||||
$values['title'],
|
||||
$values['task_limit'],
|
||||
$values['description'],
|
||||
isset($values['hide_in_dashboard']) ? $values['hide_in_dashboard'] : 0
|
||||
);
|
||||
|
||||
if ($result !== false) {
|
||||
$this->flash->success(t('Column created successfully.'));
|
||||
return $this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])), true);
|
||||
} else {
|
||||
|
|
@ -111,7 +119,15 @@ class ColumnController extends BaseController
|
|||
list($valid, $errors) = $this->columnValidator->validateModification($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->columnModel->update($values['id'], $values['title'], $values['task_limit'], $values['description'], $values['hide_in_dashboard']) !== false) {
|
||||
$result = $this->columnModel->update(
|
||||
$values['id'],
|
||||
$values['title'],
|
||||
$values['task_limit'],
|
||||
$values['description'],
|
||||
isset($values['hide_in_dashboard']) ? $values['hide_in_dashboard'] : 0
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
$this->flash->success(t('Board updated successfully.'));
|
||||
return $this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
'Global tags' => 'Globale Schlagwörter',
|
||||
'There is no global tag at the moment.' => 'Es gibt zur Zeit kein globales Schlagwort',
|
||||
'This field cannot be empty' => 'Dieses Feld kann nicht leer sein',
|
||||
'Hide tasks in this column in the Dashboard' => 'Aufgaben in dieser Spalte im Dashboard ausblenden',
|
||||
'Hide tasks in this column in the dashboard' => 'Aufgaben in dieser Spalte im Dashboard ausblenden',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1217,5 +1217,5 @@ return array(
|
|||
'Global tags' => 'Libellés globaux',
|
||||
'There is no global tag at the moment.' => 'Il n\'y a aucun libellé global pour le moment.',
|
||||
'This field cannot be empty' => 'Ce champ ne peut être vide',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
'Global tags' => 'Tag globali',
|
||||
'There is no global tag at the moment.' => 'Non sono definiti tag globali al momento.',
|
||||
'This field cannot be empty' => 'Questo campo non può essere vuoto',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
//' Hide tasks in this column in the Dashboard' => '',
|
||||
//' Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
'Global tags' => 'Etiquetas globais',
|
||||
'There is no global tag at the moment.' => 'De momento não existe nenhuma etiqueta global.',
|
||||
// 'This field cannot be empty' => '',
|
||||
//'Hide tasks in this column in the Dashboard' => '',
|
||||
//'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
'Global tags' => 'Глобальные метка',
|
||||
'There is no global tag at the moment.' => 'Нет глобальных меток.',
|
||||
'This field cannot be empty' => 'Это поле не может быть пустым',
|
||||
'Hide tasks in this column in the Dashboard' => 'Не показывать задачи из этой колонки в кабинете',
|
||||
'Hide tasks in this column in the dashboard' => 'Не показывать задачи из этой колонки в кабинете',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1216,5 +1216,5 @@ return array(
|
|||
// 'Global tags' => '',
|
||||
// 'There is no global tag at the moment.' => '',
|
||||
// 'This field cannot be empty' => '',
|
||||
// 'Hide tasks in this column in the Dashboard' => '',
|
||||
// 'Hide tasks in this column in the dashboard' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -138,11 +138,12 @@ class ColumnModel extends Base
|
|||
* Add a new column to the board
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param string $title Column title
|
||||
* @param integer $task_limit Task limit
|
||||
* @param string $description Column description
|
||||
* @return boolean|integer
|
||||
* @param integer $project_id Project id
|
||||
* @param string $title Column title
|
||||
* @param integer $task_limit Task limit
|
||||
* @param string $description Column description
|
||||
* @param integer $hide_in_dashboard
|
||||
* @return bool|int
|
||||
*/
|
||||
public function create($project_id, $title, $task_limit = 0, $description = '', $hide_in_dashboard = 0)
|
||||
{
|
||||
|
|
@ -166,6 +167,7 @@ class ColumnModel extends Base
|
|||
* @param string $title Column title
|
||||
* @param integer $task_limit Task limit
|
||||
* @param string $description Optional description
|
||||
* @param integer $hide_in_dashboard
|
||||
* @return boolean
|
||||
*/
|
||||
public function update($column_id, $title, $task_limit = 0, $description = '', $hide_in_dashboard = 0)
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ CREATE TABLE `columns` (
|
|||
`position` int(11) NOT NULL,
|
||||
`project_id` int(11) NOT NULL,
|
||||
`task_limit` int(11) DEFAULT '0',
|
||||
`hide_in_dashboard` int(11) DEFAULT '0',
|
||||
`description` text,
|
||||
`hide_in_dashboard` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_title_project` (`title`,`project_id`),
|
||||
KEY `columns_project_idx` (`project_id`),
|
||||
|
|
@ -700,4 +700,4 @@ UNLOCK TABLES;
|
|||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$Kv6fus67I/ZG/3LYJ7bRLeis8bk8455Lwtu12ElgnGm3lhRs/z7Ni', 'app-admin');INSERT INTO schema_version VALUES ('111');
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$g28mYPBdsf3/gX/ayd7A8.HSPBRQ/zM/PXlfijelJhXwhnukCRIDi', 'app-admin');INSERT INTO schema_version VALUES ('112');
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ CREATE TABLE "columns" (
|
|||
"position" integer,
|
||||
"project_id" integer NOT NULL,
|
||||
"task_limit" integer DEFAULT 0,
|
||||
"hide_in_dashboard" integer DEFAULT 0,
|
||||
"description" "text"
|
||||
"description" "text",
|
||||
"hide_in_dashboard" boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -2243,7 +2243,8 @@ INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_high
|
|||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_public_refresh_interval', '60', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_private_refresh_interval', '10', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('board_columns', '', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('webhook_token', '1aff324d30632aaed0d4f4dc1281be0d5bbc7b4fcddccc4badcd6c8f3d43', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('webhook_token', 'c9a7c2a4523f1724b2ca047c5685f8e2b26bba47eb69baf4f22d5d50d837', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('api_token', 'c57a6cb1789269547b616454e4e2f06d3de0514f83baf8fa5b5a8af44a08', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_language', 'en_US', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_timezone', 'UTC', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('application_url', '', 0, 0);
|
||||
|
|
@ -2261,7 +2262,6 @@ INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('default_co
|
|||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('subtask_time_tracking', '1', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('cfd_include_closed_tasks', '1', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('password_reset', '1', 0, 0);
|
||||
INSERT INTO settings (option, value, changed_by, changed_on) VALUES ('api_token', '19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929', 0, 0);
|
||||
|
||||
|
||||
--
|
||||
|
|
@ -2313,4 +2313,4 @@ SELECT pg_catalog.setval('links_id_seq', 11, true);
|
|||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$Kv6fus67I/ZG/3LYJ7bRLeis8bk8455Lwtu12ElgnGm3lhRs/z7Ni', 'app-admin');INSERT INTO schema_version VALUES ('90');
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$g28mYPBdsf3/gX/ayd7A8.HSPBRQ/zM/PXlfijelJhXwhnukCRIDi', 'app-admin');INSERT INTO schema_version VALUES ('91');
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<?= $this->form->label(t('Task limit'), 'task_limit') ?>
|
||||
<?= $this->form->number('task_limit', $values, $errors) ?>
|
||||
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the Dashboard'), 1) ?>
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the dashboard'), 1) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<?= $this->form->label(t('Task limit'), 'task_limit') ?>
|
||||
<?= $this->form->number('task_limit', $values, $errors) ?>
|
||||
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the Dashboard'), 1, $values['hide_in_dashboard'] == 1) ?>
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the dashboard'), 1, $values['hide_in_dashboard'] == 1) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
<th class="column-40"><?= t('Column') ?></th>
|
||||
<th class="column-20"><?= t('Task limit') ?></th>
|
||||
<th class="column-20"><?= t('Active tasks') ?></th>
|
||||
<th class="column-20"><?= t('Hide tasks in this column in the Dashboard') ?></th>
|
||||
<th class="column-20"><?= t('Hide tasks in this column in the dashboard') ?></th>
|
||||
</tr>
|
||||
<?php foreach ($stats['columns'] as $column): ?>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Kanboard\Model\ColumnModel;
|
||||
use Kanboard\Model\TaskCreationModel;
|
||||
use Kanboard\Model\TaskFinderModel;
|
||||
use Kanboard\Model\ProjectModel;
|
||||
|
||||
class TaskFinderModelTest extends Base
|
||||
{
|
||||
public function testGetTasksForDashboard()
|
||||
{
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$columnModel = new ColumnModel($this->container);
|
||||
|
||||
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
|
||||
|
||||
$tasks = $taskFinderModel->getUserQuery(1)->findAll();
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$this->assertTrue($columnModel->update(2, 'Test', 0, '', 1));
|
||||
|
||||
$tasks = $taskFinderModel->getUserQuery(1)->findAll();
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
|
||||
$this->assertTrue($columnModel->update(2, 'Test', 0, '', 0));
|
||||
|
||||
$tasks = $taskFinderModel->getUserQuery(1)->findAll();
|
||||
$this->assertCount(2, $tasks);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasks()
|
||||
{
|
||||
$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(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 1)));
|
||||
|
||||
$tasks = $taskFinderModel->getOverdueTasks();
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByProject()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $taskCreationModel->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $taskFinderModel->getOverdueTasksByProject(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByUser()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $taskCreationModel->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $taskFinderModel->getOverdueTasksByUser(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$this->assertEquals(1, $tasks[0]['id']);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
$this->assertEquals(1, $tasks[0]['owner_id']);
|
||||
$this->assertEquals(1, $tasks[0]['project_id']);
|
||||
$this->assertEquals('Project #1', $tasks[0]['project_name']);
|
||||
$this->assertEquals('admin', $tasks[0]['assignee_username']);
|
||||
$this->assertEquals('', $tasks[0]['assignee_name']);
|
||||
|
||||
$this->assertEquals('Task #2', $tasks[1]['title']);
|
||||
}
|
||||
|
||||
public function testCountByProject()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2)));
|
||||
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 2)));
|
||||
|
||||
$this->assertEquals(1, $taskFinderModel->countByProjectId(1));
|
||||
$this->assertEquals(2, $taskFinderModel->countByProjectId(2));
|
||||
}
|
||||
|
||||
public function testGetProjectToken()
|
||||
{
|
||||
$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')));
|
||||
|
||||
$this->assertTrue($projectModel->enablePublicAccess(1));
|
||||
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2)));
|
||||
|
||||
$project = $projectModel->getById(1);
|
||||
$this->assertEquals($project['token'], $taskFinderModel->getProjectToken(1));
|
||||
$this->assertEmpty($taskFinderModel->getProjectToken(2));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Kanboard\Model\TaskCreationModel;
|
||||
use Kanboard\Model\TaskFinderModel;
|
||||
use Kanboard\Model\ProjectModel;
|
||||
|
||||
class TaskFinderTest extends Base
|
||||
{
|
||||
public function testGetOverdueTasks()
|
||||
{
|
||||
$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'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #3', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasks();
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByProject()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasksByProject(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testGetOverdueTasksByUser()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2, 'owner_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'date_due' => 0)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1)));
|
||||
|
||||
$tasks = $tf->getOverdueTasksByUser(1);
|
||||
$this->assertNotEmpty($tasks);
|
||||
$this->assertTrue(is_array($tasks));
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$this->assertEquals(1, $tasks[0]['id']);
|
||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||
$this->assertEquals(1, $tasks[0]['owner_id']);
|
||||
$this->assertEquals(1, $tasks[0]['project_id']);
|
||||
$this->assertEquals('Project #1', $tasks[0]['project_name']);
|
||||
$this->assertEquals('admin', $tasks[0]['assignee_username']);
|
||||
$this->assertEquals('', $tasks[0]['assignee_name']);
|
||||
|
||||
$this->assertEquals('Task #2', $tasks[1]['title']);
|
||||
}
|
||||
|
||||
public function testCountByProject()
|
||||
{
|
||||
$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')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 2)));
|
||||
|
||||
$this->assertEquals(1, $tf->countByProjectId(1));
|
||||
$this->assertEquals(2, $tf->countByProjectId(2));
|
||||
}
|
||||
|
||||
public function testGetProjectToken()
|
||||
{
|
||||
$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')));
|
||||
|
||||
$this->assertTrue($projectModel->enablePublicAccess(1));
|
||||
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2)));
|
||||
|
||||
$project = $projectModel->getById(1);
|
||||
$this->assertEquals($project['token'], $taskFinderModel->getProjectToken(1));
|
||||
$this->assertEmpty($taskFinderModel->getProjectToken(2));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue