Rewrite integration tests to run with Docker containers

This commit is contained in:
Frederic Guillot
2016-06-25 14:34:46 -04:00
parent fc93203e4d
commit 922e0fb6de
49 changed files with 1337 additions and 1637 deletions

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -9,7 +9,7 @@ use Kanboard\Api\BoardApi;
use Kanboard\Api\CategoryApi;
use Kanboard\Api\ColumnApi;
use Kanboard\Api\CommentApi;
use Kanboard\Api\FileApi;
use Kanboard\Api\TaskFileApi;
use Kanboard\Api\GroupApi;
use Kanboard\Api\GroupMemberApi;
use Kanboard\Api\LinkApi;
@@ -56,7 +56,7 @@ class ApiProvider implements ServiceProviderInterface
->withObject(new ColumnApi($container))
->withObject(new CategoryApi($container))
->withObject(new CommentApi($container))
->withObject(new FileApi($container))
->withObject(new TaskFileApi($container))
->withObject(new LinkApi($container))
->withObject(new ProjectApi($container))
->withObject(new ProjectPermissionApi($container))