diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-18 22:37:00 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-18 22:37:00 -0400 |
commit | e8228c3975bb7cf2179d2ba670aa55d3e7780f3c (patch) | |
tree | 8f5ce7b8fd5c465b2dc4f1128fc82be93665f919 /app/Api | |
parent | 1fa72295f20aa9794f1b33dfde95960c34d85366 (diff) |
Add some tests
Diffstat (limited to 'app/Api')
-rw-r--r-- | app/Api/Base.php | 10 | ||||
-rw-r--r-- | app/Api/Me.php | 12 |
2 files changed, 13 insertions, 9 deletions
diff --git a/app/Api/Base.php b/app/Api/Base.php index c1be1878..fef36e0c 100644 --- a/app/Api/Base.php +++ b/app/Api/Base.php @@ -19,8 +19,8 @@ abstract class Base extends \Core\Base 'getMyActivityStream', 'createMyPrivateProject', 'getMyProjectsList', - 'getMyOverdueTasks', 'getMyProjects', + 'getMyOverdueTasks', ); private $both_allowed_procedures = array( @@ -70,7 +70,7 @@ abstract class Base extends \Core\Base } } - protected function formatTask($task) + protected function formatTask(array $task) { if (! empty($task)) { $task['url'] = $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true); @@ -80,7 +80,7 @@ abstract class Base extends \Core\Base return $task; } - protected function formatTasks($tasks) + protected function formatTasks(array $tasks) { if (! empty($tasks)) { foreach ($tasks as &$task) { @@ -91,7 +91,7 @@ abstract class Base extends \Core\Base return $tasks; } - protected function formatProject($project) + protected function formatProject(array $project) { if (! empty($project)) { $project['url'] = array( @@ -104,7 +104,7 @@ abstract class Base extends \Core\Base return $project; } - protected function formatProjects($projects) + protected function formatProjects(array $projects) { if (! empty($projects)) { foreach ($projects as &$project) { diff --git a/app/Api/Me.php b/app/Api/Me.php index ff317557..e7611554 100644 --- a/app/Api/Me.php +++ b/app/Api/Me.php @@ -33,7 +33,8 @@ class Me extends Base public function getMyActivityStream() { - return $this->projectActivity->getProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()), 100); + $project_ids = $this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()); + return $this->projectActivity->getProjects($project_ids, 100); } public function createMyPrivateProject($name, $description = null) @@ -52,14 +53,17 @@ class Me extends Base { return $this->projectPermission->getMemberProjects($this->userSession->getId()); } - + public function getMyOverdueTasks() { return $this->taskFinder->getOverdueTasksByUser($this->userSession->getId()); } - + public function getMyProjects() { - return $this->formatProjects($this->project->getAllByIds($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()))); + $project_ids = $this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()); + $projects = $this->project->getAllByIds($project_ids); + + return $this->formatProjects($projects); } } |