diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-25 14:34:46 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-25 14:34:46 -0400 |
commit | 922e0fb6de06a98774418612e0b0f75af72b6dbb (patch) | |
tree | dff0b7c2c8cd0515b22c8f320cdcf58c47515a98 /app/Api | |
parent | fc93203e4db044d37c1686fef0efb1ac1d6ac4b8 (diff) |
Rewrite integration tests to run with Docker containers
Diffstat (limited to 'app/Api')
-rw-r--r-- | app/Api/BaseApi.php | 11 | ||||
-rw-r--r-- | app/Api/ProjectApi.php | 8 | ||||
-rw-r--r-- | app/Api/ProjectPermissionApi.php | 18 | ||||
-rw-r--r-- | app/Api/TaskApi.php | 10 | ||||
-rw-r--r-- | app/Api/TaskFileApi.php (renamed from app/Api/FileApi.php) | 38 | ||||
-rw-r--r-- | app/Api/UserApi.php | 13 |
6 files changed, 23 insertions, 75 deletions
diff --git a/app/Api/BaseApi.php b/app/Api/BaseApi.php index 9f69aa65..8f18802c 100644 --- a/app/Api/BaseApi.php +++ b/app/Api/BaseApi.php @@ -71,4 +71,15 @@ abstract class BaseApi extends Base return $projects; } + + protected function filterValues(array $values) + { + foreach ($values as $key => $value) { + if (is_null($value)) { + unset($values[$key]); + } + } + + return $values; + } } diff --git a/app/Api/ProjectApi.php b/app/Api/ProjectApi.php index 29a9cd79..a726d4eb 100644 --- a/app/Api/ProjectApi.php +++ b/app/Api/ProjectApi.php @@ -73,13 +73,13 @@ class ProjectApi extends BaseApi return $valid ? $this->projectModel->create($values) : false; } - public function updateProject($id, $name, $description = null) + public function updateProject($project_id, $name, $description = null) { - $values = array( - 'id' => $id, + $values = $this->filterValues(array( + 'id' => $project_id, 'name' => $name, 'description' => $description - ); + )); list($valid, ) = $this->projectValidator->validateModification($values); return $valid && $this->projectModel->update($values); diff --git a/app/Api/ProjectPermissionApi.php b/app/Api/ProjectPermissionApi.php index 703cd0f3..37c5e13c 100644 --- a/app/Api/ProjectPermissionApi.php +++ b/app/Api/ProjectPermissionApi.php @@ -52,22 +52,4 @@ class ProjectPermissionApi extends Base { return $this->projectGroupRoleModel->changeGroupRole($project_id, $group_id, $role); } - - // Deprecated - public function getMembers($project_id) - { - return $this->getProjectUsers($project_id); - } - - // Deprecated - public function revokeUser($project_id, $user_id) - { - return $this->removeProjectUser($project_id, $user_id); - } - - // Deprecated - public function allowUser($project_id, $user_id) - { - return $this->addProjectUser($project_id, $user_id); - } } diff --git a/app/Api/TaskApi.php b/app/Api/TaskApi.php index ddb3ac54..523bfaa0 100644 --- a/app/Api/TaskApi.php +++ b/app/Api/TaskApi.php @@ -139,7 +139,7 @@ class TaskApi extends BaseApi return false; } - $values = array( + $values = $this->filterValues(array( 'id' => $id, 'title' => $title, 'color_id' => $color_id, @@ -155,13 +155,7 @@ class TaskApi extends BaseApi 'recurrence_basedate' => $recurrence_basedate, 'reference' => $reference, 'priority' => $priority, - ); - - foreach ($values as $key => $value) { - if (is_null($value)) { - unset($values[$key]); - } - } + )); list($valid) = $this->taskValidator->validateApiModification($values); return $valid && $this->taskModificationModel->update($values); diff --git a/app/Api/FileApi.php b/app/Api/TaskFileApi.php index 1ed3aeb9..7b27477c 100644 --- a/app/Api/FileApi.php +++ b/app/Api/TaskFileApi.php @@ -5,12 +5,12 @@ namespace Kanboard\Api; use Kanboard\Core\ObjectStorage\ObjectStorageException; /** - * File API controller + * Task File API controller * * @package Kanboard\Api * @author Frederic Guillot */ -class FileApi extends BaseApi +class TaskFileApi extends BaseApi { public function getTaskFile($file_id) { @@ -33,7 +33,7 @@ class FileApi extends BaseApi } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); } - + return ''; } @@ -56,36 +56,4 @@ class FileApi extends BaseApi { return $this->taskFileModel->removeAll($task_id); } - - // Deprecated procedures - - public function getFile($file_id) - { - return $this->getTaskFile($file_id); - } - - public function getAllFiles($task_id) - { - return $this->getAllTaskFiles($task_id); - } - - public function downloadFile($file_id) - { - return $this->downloadTaskFile($file_id); - } - - public function createFile($project_id, $task_id, $filename, $blob) - { - return $this->createTaskFile($project_id, $task_id, $filename, $blob); - } - - public function removeFile($file_id) - { - return $this->removeTaskFile($file_id); - } - - public function removeAllFiles($task_id) - { - return $this->removeAllTaskFiles($task_id); - } } diff --git a/app/Api/UserApi.php b/app/Api/UserApi.php index 88d75527..6cb9df1c 100644 --- a/app/Api/UserApi.php +++ b/app/Api/UserApi.php @@ -2,7 +2,6 @@ namespace Kanboard\Api; -use Kanboard\Core\Base; use LogicException; use Kanboard\Core\Security\Role; use Kanboard\Core\Ldap\Client as LdapClient; @@ -15,7 +14,7 @@ use Kanboard\Core\Ldap\User as LdapUser; * @package Kanboard\Api * @author Frederic Guillot */ -class UserApi extends Base +class UserApi extends BaseApi { public function getUser($user_id) { @@ -118,19 +117,13 @@ class UserApi extends Base public function updateUser($id, $username = null, $name = null, $email = null, $role = null) { - $values = array( + $values = $this->filterValues(array( 'id' => $id, 'username' => $username, 'name' => $name, 'email' => $email, 'role' => $role, - ); - - foreach ($values as $key => $value) { - if (is_null($value)) { - unset($values[$key]); - } - } + )); list($valid, ) = $this->userValidator->validateApiModification($values); return $valid && $this->userModel->update($values); |