Rewrite integration tests to run with Docker containers
This commit is contained in:
parent
fc93203e4d
commit
922e0fb6de
|
|
@ -0,0 +1 @@
|
||||||
|
@daily www-data cd /var/www/html/kanboard && ./kanboard cronjob >/dev/null 2>&1
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
.git
|
||||||
|
.git*
|
||||||
|
data/*
|
||||||
|
Makefile
|
||||||
|
.*.yml
|
||||||
|
*.json
|
||||||
|
|
@ -3,6 +3,7 @@ Version 1.0.31 (unreleased)
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Rewrite integration tests to run with Docker containers
|
||||||
* Use the same task form layout everywhere
|
* Use the same task form layout everywhere
|
||||||
* Remove some tasks dropdown menus that are now available with task edit form
|
* Remove some tasks dropdown menus that are now available with task edit form
|
||||||
* Make embedded documentation available in multiple languages
|
* Make embedded documentation available in multiple languages
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,7 @@ COPY .docker/php/conf.d/local.ini /etc/php5/conf.d/
|
||||||
COPY .docker/php/php-fpm.conf /etc/php5/
|
COPY .docker/php/php-fpm.conf /etc/php5/
|
||||||
COPY .docker/nginx/nginx.conf /etc/nginx/
|
COPY .docker/nginx/nginx.conf /etc/nginx/
|
||||||
COPY .docker/kanboard/config.php /var/www/kanboard/
|
COPY .docker/kanboard/config.php /var/www/kanboard/
|
||||||
COPY .docker/kanboard/config.php /var/www/kanboard/
|
COPY .docker/crontab/cronjob.alpine /var/spool/cron/crontabs/nginx
|
||||||
COPY .docker/crontab/kanboard /var/spool/cron/crontabs/nginx
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|
|
||||||
21
Makefile
21
Makefile
|
|
@ -60,6 +60,27 @@ unittest: test-sqlite test-mysql test-postgres
|
||||||
test-browser:
|
test-browser:
|
||||||
@ phpunit -c tests/acceptance.xml
|
@ phpunit -c tests/acceptance.xml
|
||||||
|
|
||||||
|
integration-test-mysql:
|
||||||
|
@ composer install
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.mysql.yaml build
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.mysql.yaml up -d mysql app
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.mysql.yaml up tests
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.mysql.yaml down
|
||||||
|
|
||||||
|
integration-test-postgres:
|
||||||
|
@ composer install
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.postgres.yaml build
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.postgres.yaml up -d postgres app
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.postgres.yaml up tests
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.postgres.yaml down
|
||||||
|
|
||||||
|
integration-test-sqlite:
|
||||||
|
@ composer install
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml build
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml up -d app
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml up tests
|
||||||
|
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml down
|
||||||
|
|
||||||
sql:
|
sql:
|
||||||
@ pg_dump --schema-only --no-owner --no-privileges --quote-all-identifiers -n public --file app/Schema/Sql/postgres.sql kanboard
|
@ pg_dump --schema-only --no-owner --no-privileges --quote-all-identifiers -n public --file app/Schema/Sql/postgres.sql kanboard
|
||||||
@ pg_dump -d kanboard --column-inserts --data-only --table settings >> app/Schema/Sql/postgres.sql
|
@ pg_dump -d kanboard --column-inserts --data-only --table settings >> app/Schema/Sql/postgres.sql
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,15 @@ abstract class BaseApi extends Base
|
||||||
|
|
||||||
return $projects;
|
return $projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function filterValues(array $values)
|
||||||
|
{
|
||||||
|
foreach ($values as $key => $value) {
|
||||||
|
if (is_null($value)) {
|
||||||
|
unset($values[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,13 +73,13 @@ class ProjectApi extends BaseApi
|
||||||
return $valid ? $this->projectModel->create($values) : false;
|
return $valid ? $this->projectModel->create($values) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateProject($id, $name, $description = null)
|
public function updateProject($project_id, $name, $description = null)
|
||||||
{
|
{
|
||||||
$values = array(
|
$values = $this->filterValues(array(
|
||||||
'id' => $id,
|
'id' => $project_id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'description' => $description
|
'description' => $description
|
||||||
);
|
));
|
||||||
|
|
||||||
list($valid, ) = $this->projectValidator->validateModification($values);
|
list($valid, ) = $this->projectValidator->validateModification($values);
|
||||||
return $valid && $this->projectModel->update($values);
|
return $valid && $this->projectModel->update($values);
|
||||||
|
|
|
||||||
|
|
@ -52,22 +52,4 @@ class ProjectPermissionApi extends Base
|
||||||
{
|
{
|
||||||
return $this->projectGroupRoleModel->changeGroupRole($project_id, $group_id, $role);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ class TaskApi extends BaseApi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = array(
|
$values = $this->filterValues(array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'color_id' => $color_id,
|
'color_id' => $color_id,
|
||||||
|
|
@ -155,13 +155,7 @@ class TaskApi extends BaseApi
|
||||||
'recurrence_basedate' => $recurrence_basedate,
|
'recurrence_basedate' => $recurrence_basedate,
|
||||||
'reference' => $reference,
|
'reference' => $reference,
|
||||||
'priority' => $priority,
|
'priority' => $priority,
|
||||||
);
|
));
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
|
||||||
if (is_null($value)) {
|
|
||||||
unset($values[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list($valid) = $this->taskValidator->validateApiModification($values);
|
list($valid) = $this->taskValidator->validateApiModification($values);
|
||||||
return $valid && $this->taskModificationModel->update($values);
|
return $valid && $this->taskModificationModel->update($values);
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ namespace Kanboard\Api;
|
||||||
use Kanboard\Core\ObjectStorage\ObjectStorageException;
|
use Kanboard\Core\ObjectStorage\ObjectStorageException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File API controller
|
* Task File API controller
|
||||||
*
|
*
|
||||||
* @package Kanboard\Api
|
* @package Kanboard\Api
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class FileApi extends BaseApi
|
class TaskFileApi extends BaseApi
|
||||||
{
|
{
|
||||||
public function getTaskFile($file_id)
|
public function getTaskFile($file_id)
|
||||||
{
|
{
|
||||||
|
|
@ -56,36 +56,4 @@ class FileApi extends BaseApi
|
||||||
{
|
{
|
||||||
return $this->taskFileModel->removeAll($task_id);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Kanboard\Api;
|
namespace Kanboard\Api;
|
||||||
|
|
||||||
use Kanboard\Core\Base;
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Kanboard\Core\Security\Role;
|
use Kanboard\Core\Security\Role;
|
||||||
use Kanboard\Core\Ldap\Client as LdapClient;
|
use Kanboard\Core\Ldap\Client as LdapClient;
|
||||||
|
|
@ -15,7 +14,7 @@ use Kanboard\Core\Ldap\User as LdapUser;
|
||||||
* @package Kanboard\Api
|
* @package Kanboard\Api
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class UserApi extends Base
|
class UserApi extends BaseApi
|
||||||
{
|
{
|
||||||
public function getUser($user_id)
|
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)
|
public function updateUser($id, $username = null, $name = null, $email = null, $role = null)
|
||||||
{
|
{
|
||||||
$values = array(
|
$values = $this->filterValues(array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
);
|
));
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
|
||||||
if (is_null($value)) {
|
|
||||||
unset($values[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list($valid, ) = $this->userValidator->validateApiModification($values);
|
list($valid, ) = $this->userValidator->validateApiModification($values);
|
||||||
return $valid && $this->userModel->update($values);
|
return $valid && $this->userModel->update($values);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Kanboard\Api\BoardApi;
|
||||||
use Kanboard\Api\CategoryApi;
|
use Kanboard\Api\CategoryApi;
|
||||||
use Kanboard\Api\ColumnApi;
|
use Kanboard\Api\ColumnApi;
|
||||||
use Kanboard\Api\CommentApi;
|
use Kanboard\Api\CommentApi;
|
||||||
use Kanboard\Api\FileApi;
|
use Kanboard\Api\TaskFileApi;
|
||||||
use Kanboard\Api\GroupApi;
|
use Kanboard\Api\GroupApi;
|
||||||
use Kanboard\Api\GroupMemberApi;
|
use Kanboard\Api\GroupMemberApi;
|
||||||
use Kanboard\Api\LinkApi;
|
use Kanboard\Api\LinkApi;
|
||||||
|
|
@ -56,7 +56,7 @@ class ApiProvider implements ServiceProviderInterface
|
||||||
->withObject(new ColumnApi($container))
|
->withObject(new ColumnApi($container))
|
||||||
->withObject(new CategoryApi($container))
|
->withObject(new CategoryApi($container))
|
||||||
->withObject(new CommentApi($container))
|
->withObject(new CommentApi($container))
|
||||||
->withObject(new FileApi($container))
|
->withObject(new TaskFileApi($container))
|
||||||
->withObject(new LinkApi($container))
|
->withObject(new LinkApi($container))
|
||||||
->withObject(new ProjectApi($container))
|
->withObject(new ProjectApi($container))
|
||||||
->withObject(new ProjectPermissionApi($container))
|
->withObject(new ProjectPermissionApi($container))
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ Response example:
|
||||||
|
|
||||||
- Purpose: **Update a project**
|
- Purpose: **Update a project**
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- **id** (integer, required)
|
- **project_id** (integer, required)
|
||||||
- **name** (string, required)
|
- **name** (string, required)
|
||||||
- **description** (string, optional)
|
- **description** (string, optional)
|
||||||
- Result on success: **true**
|
- Result on success: **true**
|
||||||
|
|
@ -197,7 +197,7 @@ Request example:
|
||||||
"method": "updateProject",
|
"method": "updateProject",
|
||||||
"id": 1853996288,
|
"id": 1853996288,
|
||||||
"params": {
|
"params": {
|
||||||
"id": 1,
|
"project_id": 1,
|
||||||
"name": "PHP client update"
|
"name": "PHP client update"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Linux/Unix machine
|
- Linux/Unix machine
|
||||||
- PHP cli
|
- PHP
|
||||||
- PHPUnit installed
|
- PHPUnit installed
|
||||||
- Mysql and Postgresql (optional)
|
- Mysql and Postgresql (optional)
|
||||||
- Selenium (optional)
|
- Selenium (optional)
|
||||||
|
|
@ -85,46 +85,37 @@ From your Kanboard directory, run the command `phpunit -c tests/units.postgres.x
|
||||||
Integration Tests
|
Integration Tests
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
Acceptance tests (also known as end-to-end tests and sometimes functional tests) allow us to test the actual functionality of the browser using Selenium and PHPUnit.
|
Integration tests are mainly used to test the API.
|
||||||
|
The test suites are making real HTTP calls to the application that run inside a container.
|
||||||
|
|
||||||
The PHPUnit config file is `tests/acceptance.xml`.
|
### Requirements
|
||||||
From your Kanboard directory, run the command `phpunit -c tests/units.sqlite.xml`.
|
|
||||||
|
|
||||||
Actually only the API calls are tested.
|
- PHP
|
||||||
|
- Composer
|
||||||
|
- Unix operating system (Mac OS or Linux)
|
||||||
|
- Docker
|
||||||
|
- Docker Compose
|
||||||
|
|
||||||
Real HTTP calls are made with those tests.
|
### Running integration tests
|
||||||
So a local instance of Kanboard is necessary and must listen on `http://localhost:8000/`.
|
|
||||||
|
|
||||||
All data will be removed/altered by the test suite.
|
Integration tests are using Docker containers.
|
||||||
Moreover the script will reset and set a new API key.
|
There are 3 different environment available to run tests against each supported database.
|
||||||
|
|
||||||
1. Start a local instance of Kanboard `php -S 127.0.0.1:8000`
|
You can use these commands to run each test suite:
|
||||||
2. Run the test suite from another terminal
|
|
||||||
|
|
||||||
The same method as above is used to run tests across different databases:
|
|
||||||
|
|
||||||
- Sqlite: `phpunit -c tests/integration.sqlite.xml`
|
|
||||||
- Mysql: `phpunit -c tests/integration.mysql.xml`
|
|
||||||
- Postgresql: `phpunit -c tests/integration.postgres.xml`
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
phpunit -c tests/integration.sqlite.xml
|
# Run tests with Sqlite
|
||||||
|
make integration-test-sqlite
|
||||||
|
|
||||||
PHPUnit 5.0.0 by Sebastian Bergmann and contributors.
|
# Run tests with Mysql
|
||||||
|
make integration-test-mysql
|
||||||
|
|
||||||
............................................................... 63 / 135 ( 46%)
|
# Run tests with Postgres
|
||||||
............................................................... 126 / 135 ( 93%)
|
make integration-test-postgres
|
||||||
......... 135 / 135 (100%)
|
|
||||||
|
|
||||||
Time: 1.18 minutes, Memory: 14.75Mb
|
|
||||||
|
|
||||||
OK (135 tests, 526 assertions)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Acceptance Tests
|
Acceptance Tests
|
||||||
-----------------
|
----------------
|
||||||
|
|
||||||
Acceptance tests (also sometimes known as end-to-end tests, and functional tests) test the actual functionality of the UI in a browser using Selenium.
|
Acceptance tests (also sometimes known as end-to-end tests, and functional tests) test the actual functionality of the UI in a browser using Selenium.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('DB_DRIVER', 'mysql');
|
||||||
|
define('DB_USERNAME', 'root');
|
||||||
|
define('DB_PASSWORD', 'kanboard');
|
||||||
|
define('DB_HOSTNAME', 'mysql');
|
||||||
|
define('DB_NAME', 'kanboard');
|
||||||
|
|
||||||
|
define('DEBUG', true);
|
||||||
|
define('LOG_DRIVER', 'stderr');
|
||||||
|
|
||||||
|
define('API_AUTHENTICATION_TOKEN', 'test');
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('DB_DRIVER', 'postgres');
|
||||||
|
define('DB_USERNAME', 'postgres');
|
||||||
|
define('DB_PASSWORD', 'postgres');
|
||||||
|
define('DB_HOSTNAME', 'postgres');
|
||||||
|
define('DB_NAME', 'kanboard');
|
||||||
|
|
||||||
|
define('DEBUG', true);
|
||||||
|
define('LOG_DRIVER', 'stderr');
|
||||||
|
|
||||||
|
define('API_AUTHENTICATION_TOKEN', 'test');
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('DB_DRIVER', 'sqlite');
|
||||||
|
|
||||||
|
define('DEBUG', true);
|
||||||
|
define('LOG_DRIVER', 'file');
|
||||||
|
|
||||||
|
define('API_AUTHENTICATION_TOKEN', 'test');
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/supervisor
|
||||||
|
|
||||||
|
RUN apt-get update -qq && \
|
||||||
|
apt-get install -y apache2 supervisor cron curl unzip \
|
||||||
|
libapache2-mod-php7.0 php7.0-cli php7.0-mbstring php7.0-xml php7.0-mysql php7.0-sqlite3 \
|
||||||
|
php7.0-opcache php7.0-json php7.0-pgsql php7.0-ldap php7.0-gd php7.0-zip && \
|
||||||
|
apt clean && \
|
||||||
|
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
|
||||||
|
sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf && \
|
||||||
|
a2enmod rewrite && \
|
||||||
|
curl -sS https://getcomposer.org/installer | php -- --filename=/usr/local/bin/composer
|
||||||
|
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
RUN chown -R www-data:www-data /var/www/html/data /var/www/html/plugins
|
||||||
|
|
||||||
|
COPY tests/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
COPY tests/configs /configs/
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["/var/www/html/tests/docker/entrypoint.sh"]
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "kanboard"
|
||||||
|
MYSQL_DATABASE: "kanboard"
|
||||||
|
MYSQL_USER: "kanboard"
|
||||||
|
MYSQL_PASSWORD: "kanboard"
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
command: config-mysql
|
||||||
|
tests:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
command: integration-test-mysql
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:9.5
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: kanboard
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
command: config-postgres
|
||||||
|
tests:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
command: integration-test-postgres
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
command: config-sqlite
|
||||||
|
tests:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: tests/docker/Dockerfile.xenial
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
command: integration-test-sqlite
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function wait_schema_creation() {
|
||||||
|
curl -s http://app/login > /dev/null
|
||||||
|
sleep $1
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"config-sqlite")
|
||||||
|
cp /configs/config.sqlite.php /var/www/html/config.php
|
||||||
|
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
;;
|
||||||
|
"config-postgres")
|
||||||
|
cp /configs/config.postgres.php /var/www/html/config.php
|
||||||
|
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
;;
|
||||||
|
"config-mysql")
|
||||||
|
cp /configs/config.mysql.php /var/www/html/config.php
|
||||||
|
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
;;
|
||||||
|
"integration-test-sqlite")
|
||||||
|
wait_schema_creation 1
|
||||||
|
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.sqlite.xml
|
||||||
|
;;
|
||||||
|
"integration-test-postgres")
|
||||||
|
wait_schema_creation 5
|
||||||
|
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.postgres.xml
|
||||||
|
;;
|
||||||
|
"integration-test-mysql")
|
||||||
|
wait_schema_creation 15
|
||||||
|
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.mysql.xml
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
|
||||||
|
[program:apache2]
|
||||||
|
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
|
||||||
|
autorestart=true
|
||||||
|
|
@ -5,16 +5,8 @@
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<php>
|
<php>
|
||||||
<const name="API_URL" value="http://localhost:8000/jsonrpc.php" />
|
<const name="BASE_URL" value="http://app/" />
|
||||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||||
<const name="DB_DRIVER" value="mysql" />
|
<const name="API_KEY" value="test" />
|
||||||
<const name="DB_NAME" value="kanboard" />
|
|
||||||
<const name="DB_HOSTNAME" value="localhost" />
|
|
||||||
<const name="DB_USERNAME" value="root" />
|
|
||||||
<const name="DB_PASSWORD" value="" />
|
|
||||||
<const name="DB_PORT" value="" />
|
|
||||||
<const name="DB_SSL_KEY" value="" />
|
|
||||||
<const name="DB_SSL_CA" value="" />
|
|
||||||
<const name="DB_SSL_CERT" value="" />
|
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,8 @@
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<php>
|
<php>
|
||||||
<const name="API_URL" value="http://localhost:8000/jsonrpc.php" />
|
<const name="BASE_URL" value="http://app/" />
|
||||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||||
<const name="DB_DRIVER" value="postgres" />
|
<const name="API_KEY" value="test" />
|
||||||
<const name="DB_NAME" value="kanboard" />
|
|
||||||
<const name="DB_HOSTNAME" value="localhost" />
|
|
||||||
<const name="DB_USERNAME" value="postgres" />
|
|
||||||
<const name="DB_PASSWORD" value="postgres" />
|
|
||||||
<const name="DB_PORT" value="" />
|
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
@ -5,9 +5,8 @@
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<php>
|
<php>
|
||||||
<const name="API_URL" value="http://127.0.0.1:8000/jsonrpc.php" />
|
<const name="BASE_URL" value="http://app/" />
|
||||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||||
<const name="DB_DRIVER" value="sqlite" />
|
<const name="API_KEY" value="test" />
|
||||||
<const name="DB_FILENAME" value="data/db.sqlite" />
|
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class ActionTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test actions';
|
||||||
|
|
||||||
|
public function testGetAvailableActions()
|
||||||
|
{
|
||||||
|
$actions = $this->app->getAvailableActions();
|
||||||
|
$this->assertNotEmpty($actions);
|
||||||
|
$this->assertInternalType('array', $actions);
|
||||||
|
$this->assertArrayHasKey('\Kanboard\Action\TaskCloseColumn', $actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetAvailableActionEvents()
|
||||||
|
{
|
||||||
|
$events = $this->app->getAvailableActionEvents();
|
||||||
|
$this->assertNotEmpty($events);
|
||||||
|
$this->assertInternalType('array', $events);
|
||||||
|
$this->assertArrayHasKey('task.move.column', $events);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetCompatibleActionEvents()
|
||||||
|
{
|
||||||
|
$events = $this->app->getCompatibleActionEvents('\Kanboard\Action\TaskCloseColumn');
|
||||||
|
$this->assertNotEmpty($events);
|
||||||
|
$this->assertInternalType('array', $events);
|
||||||
|
$this->assertArrayHasKey('task.move.column', $events);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCRUD()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateAction();
|
||||||
|
$this->assertGetActions();
|
||||||
|
$this->assertRemoveAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateAction()
|
||||||
|
{
|
||||||
|
$actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1));
|
||||||
|
$this->assertNotFalse($actionId);
|
||||||
|
$this->assertTrue($actionId > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetActions()
|
||||||
|
{
|
||||||
|
$actions = $this->app->getActions($this->projectId);
|
||||||
|
$this->assertNotEmpty($actions);
|
||||||
|
$this->assertInternalType('array', $actions);
|
||||||
|
$this->assertArrayHasKey('id', $actions[0]);
|
||||||
|
$this->assertArrayHasKey('project_id', $actions[0]);
|
||||||
|
$this->assertArrayHasKey('event_name', $actions[0]);
|
||||||
|
$this->assertArrayHasKey('action_name', $actions[0]);
|
||||||
|
$this->assertArrayHasKey('params', $actions[0]);
|
||||||
|
$this->assertArrayHasKey('column_id', $actions[0]['params']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveAction()
|
||||||
|
{
|
||||||
|
$actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1));
|
||||||
|
$this->assertTrue($this->app->removeAction($actionId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,928 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__.'/../../vendor/autoload.php';
|
|
||||||
|
|
||||||
class Api extends PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
private $client = null;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (DB_DRIVER === 'sqlite') {
|
|
||||||
@unlink(DB_FILENAME);
|
|
||||||
} elseif (DB_DRIVER === 'mysql') {
|
|
||||||
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
|
||||||
$pdo->exec('DROP DATABASE '.DB_NAME);
|
|
||||||
$pdo->exec('CREATE DATABASE '.DB_NAME);
|
|
||||||
$pdo = null;
|
|
||||||
} elseif (DB_DRIVER === 'postgres') {
|
|
||||||
$pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
|
||||||
$pdo->exec('DROP DATABASE '.DB_NAME);
|
|
||||||
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
|
|
||||||
$pdo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$service = new Kanboard\ServiceProvider\DatabaseProvider;
|
|
||||||
|
|
||||||
$db = $service->getInstance();
|
|
||||||
$db->table('settings')->eq('option', 'api_token')->update(array('value' => API_KEY));
|
|
||||||
$db->table('settings')->eq('option', 'application_timezone')->update(array('value' => 'Europe/Paris'));
|
|
||||||
$db->closeConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->client = new JsonRPC\Client(API_URL);
|
|
||||||
$this->client->authentication('jsonrpc', API_KEY);
|
|
||||||
// $this->client->debug = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getTaskId()
|
|
||||||
{
|
|
||||||
$tasks = $this->client->getAllTasks(1, 1);
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
|
|
||||||
return $tasks[0]['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveAll()
|
|
||||||
{
|
|
||||||
$projects = $this->client->getAllProjects();
|
|
||||||
|
|
||||||
if ($projects) {
|
|
||||||
foreach ($projects as $project) {
|
|
||||||
$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']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateProject()
|
|
||||||
{
|
|
||||||
$project_id = $this->client->createProject('API test');
|
|
||||||
$this->assertNotFalse($project_id);
|
|
||||||
$this->assertInternalType('int', $project_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetProjectById()
|
|
||||||
{
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(1, $project['id']);
|
|
||||||
$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()
|
|
||||||
{
|
|
||||||
$project = $this->client->getProjectByName('API test');
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(1, $project['id']);
|
|
||||||
$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);
|
|
||||||
$this->assertEquals(1, $project['id']);
|
|
||||||
|
|
||||||
$project = $this->client->getProjectByName('None');
|
|
||||||
$this->assertEmpty($project);
|
|
||||||
$this->assertNull($project);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllProjects()
|
|
||||||
{
|
|
||||||
$projects = $this->client->getAllProjects();
|
|
||||||
$this->assertNotEmpty($projects);
|
|
||||||
|
|
||||||
foreach ($projects as $project) {
|
|
||||||
$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 testUpdateProject()
|
|
||||||
{
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertTrue($this->client->execute('updateProject', array('id' => 1, 'name' => 'API test 2')));
|
|
||||||
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertEquals('API test 2', $project['name']);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateProject', array('id' => 1, 'name' => 'API test', 'description' => 'test')));
|
|
||||||
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertEquals('API test', $project['name']);
|
|
||||||
$this->assertEquals('test', $project['description']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDisableProject()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->disableProject(1));
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(0, $project['is_active']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEnableProject()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->enableProject(1));
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(1, $project['is_active']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEnableProjectPublicAccess()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->enableProjectPublicAccess(1));
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(1, $project['is_public']);
|
|
||||||
$this->assertNotEmpty($project['token']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDisableProjectPublicAccess()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->disableProjectPublicAccess(1));
|
|
||||||
$project = $this->client->getProjectById(1);
|
|
||||||
$this->assertNotEmpty($project);
|
|
||||||
$this->assertEquals(0, $project['is_public']);
|
|
||||||
$this->assertEmpty($project['token']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testgetProjectActivities()
|
|
||||||
{
|
|
||||||
$activities = $this->client->getProjectActivities(array('project_ids' => array(1)));
|
|
||||||
$this->assertInternalType('array', $activities);
|
|
||||||
$this->assertCount(0, $activities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testgetProjectActivity()
|
|
||||||
{
|
|
||||||
$activities = $this->client->getProjectActivity(1);
|
|
||||||
$this->assertInternalType('array', $activities);
|
|
||||||
$this->assertCount(0, $activities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateTaskWithWrongMember()
|
|
||||||
{
|
|
||||||
$task = array(
|
|
||||||
'title' => 'Task #1',
|
|
||||||
'color_id' => 'blue',
|
|
||||||
'owner_id' => 1,
|
|
||||||
'project_id' => 1,
|
|
||||||
'column_id' => 2,
|
|
||||||
);
|
|
||||||
|
|
||||||
$task_id = $this->client->createTask($task);
|
|
||||||
|
|
||||||
$this->assertFalse($task_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllowedUsers()
|
|
||||||
{
|
|
||||||
$users = $this->client->getMembers(1);
|
|
||||||
$this->assertNotFalse($users);
|
|
||||||
$this->assertEquals(array(), $users);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddMember()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->allowUser(1, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateTask()
|
|
||||||
{
|
|
||||||
$task = array(
|
|
||||||
'title' => 'Task #1',
|
|
||||||
'color_id' => 'blue',
|
|
||||||
'owner_id' => 1,
|
|
||||||
'project_id' => 1,
|
|
||||||
'column_id' => 2,
|
|
||||||
);
|
|
||||||
|
|
||||||
$task_id = $this->client->createTask($task);
|
|
||||||
|
|
||||||
$this->assertNotFalse($task_id);
|
|
||||||
$this->assertInternalType('int', $task_id);
|
|
||||||
$this->assertTrue($task_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testCreateTaskWithBadParams()
|
|
||||||
{
|
|
||||||
$task = array(
|
|
||||||
'title' => 'Task #1',
|
|
||||||
'color_id' => 'blue',
|
|
||||||
'owner_id' => 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->client->createTask($task);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetTask()
|
|
||||||
{
|
|
||||||
$task = $this->client->getTask(1);
|
|
||||||
|
|
||||||
$this->assertNotFalse($task);
|
|
||||||
$this->assertTrue(is_array($task));
|
|
||||||
$this->assertEquals('Task #1', $task['title']);
|
|
||||||
$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()
|
|
||||||
{
|
|
||||||
$tasks = $this->client->getAllTasks(1, 1);
|
|
||||||
|
|
||||||
$this->assertNotFalse($tasks);
|
|
||||||
$this->assertTrue(is_array($tasks));
|
|
||||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
|
||||||
$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);
|
|
||||||
|
|
||||||
$this->assertNotFalse($tasks);
|
|
||||||
$this->assertTrue(is_array($tasks));
|
|
||||||
$this->assertEmpty($tasks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveTaskSwimlane()
|
|
||||||
{
|
|
||||||
$task_id = $this->getTaskId();
|
|
||||||
|
|
||||||
$task = $this->client->getTask($task_id);
|
|
||||||
$this->assertNotFalse($task);
|
|
||||||
$this->assertTrue(is_array($task));
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
$this->assertEquals(2, $task['column_id']);
|
|
||||||
$this->assertEquals(0, $task['swimlane_id']);
|
|
||||||
|
|
||||||
$moved_timestamp = $task['date_moved'];
|
|
||||||
sleep(1);
|
|
||||||
$this->assertTrue($this->client->moveTaskPosition(1, $task_id, 4, 1, 2));
|
|
||||||
|
|
||||||
$task = $this->client->getTask($task_id);
|
|
||||||
$this->assertNotFalse($task);
|
|
||||||
$this->assertTrue(is_array($task));
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
$this->assertEquals(4, $task['column_id']);
|
|
||||||
$this->assertEquals(2, $task['swimlane_id']);
|
|
||||||
$this->assertNotEquals($moved_timestamp, $task['date_moved']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateTask()
|
|
||||||
{
|
|
||||||
$task = $this->client->getTask(1);
|
|
||||||
|
|
||||||
$values = array();
|
|
||||||
$values['id'] = $task['id'];
|
|
||||||
$values['color_id'] = 'green';
|
|
||||||
$values['description'] = 'test';
|
|
||||||
$values['date_due'] = '';
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateTask', $values));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveTask()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->removeTask(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveUsers()
|
|
||||||
{
|
|
||||||
$users = $this->client->getAllUsers();
|
|
||||||
$this->assertNotFalse($users);
|
|
||||||
$this->assertNotEmpty($users);
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
if ($user['id'] > 1) {
|
|
||||||
$this->assertTrue($this->client->removeUser($user['id']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateUser()
|
|
||||||
{
|
|
||||||
$user = array(
|
|
||||||
'username' => 'toto',
|
|
||||||
'name' => 'Toto',
|
|
||||||
'password' => '123456',
|
|
||||||
);
|
|
||||||
|
|
||||||
$user_id = $this->client->execute('createUser', $user);
|
|
||||||
$this->assertNotFalse($user_id);
|
|
||||||
$this->assertInternalType('int', $user_id);
|
|
||||||
$this->assertTrue($user_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateManagerUser()
|
|
||||||
{
|
|
||||||
$user = array(
|
|
||||||
'username' => 'manager',
|
|
||||||
'name' => 'Manager',
|
|
||||||
'password' => '123456',
|
|
||||||
'role' => 'app-manager'
|
|
||||||
);
|
|
||||||
|
|
||||||
$user_id = $this->client->execute('createUser', $user);
|
|
||||||
$this->assertNotFalse($user_id);
|
|
||||||
$this->assertInternalType('int', $user_id);
|
|
||||||
$this->assertTrue($user_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testCreateUserWithBadParams()
|
|
||||||
{
|
|
||||||
$user = array(
|
|
||||||
'name' => 'Titi',
|
|
||||||
'password' => '123456',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertNull($this->client->execute('createUser', $user));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetUser()
|
|
||||||
{
|
|
||||||
$user = $this->client->getUser(2);
|
|
||||||
$this->assertNotFalse($user);
|
|
||||||
$this->assertTrue(is_array($user));
|
|
||||||
$this->assertEquals('toto', $user['username']);
|
|
||||||
|
|
||||||
$user = $this->client->getUser(3);
|
|
||||||
$this->assertNotEmpty($user);
|
|
||||||
$this->assertEquals('app-manager', $user['role']);
|
|
||||||
|
|
||||||
$this->assertNull($this->client->getUser(2222));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetUserByName()
|
|
||||||
{
|
|
||||||
$user = $this->client->getUserByName('toto');
|
|
||||||
$this->assertNotFalse($user);
|
|
||||||
$this->assertTrue(is_array($user));
|
|
||||||
$this->assertEquals(2, $user['id']);
|
|
||||||
|
|
||||||
$user = $this->client->getUserByName('manager');
|
|
||||||
$this->assertNotEmpty($user);
|
|
||||||
$this->assertEquals('app-manager', $user['role']);
|
|
||||||
|
|
||||||
$this->assertNull($this->client->getUserByName('nonexistantusername'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateUser()
|
|
||||||
{
|
|
||||||
$user = array();
|
|
||||||
$user['id'] = 2;
|
|
||||||
$user['username'] = 'titi';
|
|
||||||
$user['name'] = 'Titi';
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateUser', $user));
|
|
||||||
|
|
||||||
$user = $this->client->getUser(2);
|
|
||||||
$this->assertNotFalse($user);
|
|
||||||
$this->assertTrue(is_array($user));
|
|
||||||
$this->assertEquals('titi', $user['username']);
|
|
||||||
$this->assertEquals('Titi', $user['name']);
|
|
||||||
|
|
||||||
$user = array();
|
|
||||||
$user['id'] = 2;
|
|
||||||
$user['email'] = 'titi@localhost';
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateUser', $user));
|
|
||||||
|
|
||||||
$user = $this->client->getUser(2);
|
|
||||||
$this->assertNotFalse($user);
|
|
||||||
$this->assertTrue(is_array($user));
|
|
||||||
$this->assertEquals('titi@localhost', $user['email']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAllowedUser()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->allowUser(1, 2));
|
|
||||||
|
|
||||||
$users = $this->client->getMembers(1);
|
|
||||||
$this->assertNotFalse($users);
|
|
||||||
$this->assertEquals(array(1 => 'admin', 2 => 'Titi'), $users);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRevokeUser()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->revokeUser(1, 2));
|
|
||||||
|
|
||||||
$users = $this->client->getMembers(1);
|
|
||||||
$this->assertNotFalse($users);
|
|
||||||
$this->assertEquals(array(1 => 'admin'), $users);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateComment()
|
|
||||||
{
|
|
||||||
$task = array(
|
|
||||||
'title' => 'Task with comment',
|
|
||||||
'color_id' => 'red',
|
|
||||||
'owner_id' => 1,
|
|
||||||
'project_id' => 1,
|
|
||||||
'column_id' => 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertNotFalse($this->client->execute('createTask', $task));
|
|
||||||
|
|
||||||
$tasks = $this->client->getAllTasks(1, 1);
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertEquals(1, count($tasks));
|
|
||||||
|
|
||||||
$comment = array(
|
|
||||||
'task_id' => $tasks[0]['id'],
|
|
||||||
'user_id' => 2,
|
|
||||||
'content' => 'boo',
|
|
||||||
);
|
|
||||||
|
|
||||||
$comment_id = $this->client->execute('createComment', $comment);
|
|
||||||
|
|
||||||
$this->assertNotFalse($comment_id);
|
|
||||||
$this->assertInternalType('int', $comment_id);
|
|
||||||
$this->assertTrue($comment_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetComment()
|
|
||||||
{
|
|
||||||
$comment = $this->client->getComment(1);
|
|
||||||
$this->assertNotFalse($comment);
|
|
||||||
$this->assertNotEmpty($comment);
|
|
||||||
$this->assertEquals(2, $comment['user_id']);
|
|
||||||
$this->assertEquals('boo', $comment['comment']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateComment()
|
|
||||||
{
|
|
||||||
$comment = array();
|
|
||||||
$comment['id'] = 1;
|
|
||||||
$comment['content'] = 'test';
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateComment', $comment));
|
|
||||||
|
|
||||||
$comment = $this->client->getComment(1);
|
|
||||||
$this->assertEquals('test', $comment['comment']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllComments()
|
|
||||||
{
|
|
||||||
$task_id = $this->getTaskId();
|
|
||||||
|
|
||||||
$comment = array(
|
|
||||||
'task_id' => $task_id,
|
|
||||||
'user_id' => 1,
|
|
||||||
'content' => 'blabla',
|
|
||||||
);
|
|
||||||
|
|
||||||
$comment_id = $this->client->createComment($comment);
|
|
||||||
|
|
||||||
$this->assertNotFalse($comment_id);
|
|
||||||
$this->assertInternalType('int', $comment_id);
|
|
||||||
$this->assertTrue($comment_id > 0);
|
|
||||||
|
|
||||||
$comments = $this->client->getAllComments($task_id);
|
|
||||||
$this->assertNotFalse($comments);
|
|
||||||
$this->assertNotEmpty($comments);
|
|
||||||
$this->assertTrue(is_array($comments));
|
|
||||||
$this->assertEquals(2, count($comments));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveComment()
|
|
||||||
{
|
|
||||||
$task_id = $this->getTaskId();
|
|
||||||
|
|
||||||
$comments = $this->client->getAllComments($task_id);
|
|
||||||
$this->assertNotFalse($comments);
|
|
||||||
$this->assertNotEmpty($comments);
|
|
||||||
$this->assertTrue(is_array($comments));
|
|
||||||
|
|
||||||
foreach ($comments as $comment) {
|
|
||||||
$this->assertTrue($this->client->removeComment($comment['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$comments = $this->client->getAllComments($task_id);
|
|
||||||
$this->assertNotFalse($comments);
|
|
||||||
$this->assertEmpty($comments);
|
|
||||||
$this->assertTrue(is_array($comments));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateSubtask()
|
|
||||||
{
|
|
||||||
$subtask = array(
|
|
||||||
'task_id' => $this->getTaskId(),
|
|
||||||
'title' => 'subtask #1',
|
|
||||||
);
|
|
||||||
|
|
||||||
$subtask_id = $this->client->createSubtask($subtask);
|
|
||||||
|
|
||||||
$this->assertNotFalse($subtask_id);
|
|
||||||
$this->assertInternalType('int', $subtask_id);
|
|
||||||
$this->assertTrue($subtask_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetSubtask()
|
|
||||||
{
|
|
||||||
$subtask = $this->client->getSubtask(1);
|
|
||||||
$this->assertNotFalse($subtask);
|
|
||||||
$this->assertNotEmpty($subtask);
|
|
||||||
$this->assertEquals($this->getTaskId(), $subtask['task_id']);
|
|
||||||
$this->assertEquals(0, $subtask['user_id']);
|
|
||||||
$this->assertEquals('subtask #1', $subtask['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateSubtask()
|
|
||||||
{
|
|
||||||
$subtask = array();
|
|
||||||
$subtask['id'] = 1;
|
|
||||||
$subtask['task_id'] = $this->getTaskId();
|
|
||||||
$subtask['title'] = 'test';
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateSubtask', $subtask));
|
|
||||||
|
|
||||||
$subtask = $this->client->getSubtask(1);
|
|
||||||
$this->assertEquals('test', $subtask['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllSubtasks()
|
|
||||||
{
|
|
||||||
$subtask = array(
|
|
||||||
'task_id' => $this->getTaskId(),
|
|
||||||
'user_id' => 2,
|
|
||||||
'title' => 'Subtask #2',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertNotFalse($this->client->execute('createSubtask', $subtask));
|
|
||||||
|
|
||||||
$subtasks = $this->client->getAllSubtasks($this->getTaskId());
|
|
||||||
$this->assertNotFalse($subtasks);
|
|
||||||
$this->assertNotEmpty($subtasks);
|
|
||||||
$this->assertTrue(is_array($subtasks));
|
|
||||||
$this->assertEquals(2, count($subtasks));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveSubtask()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->removeSubtask(1));
|
|
||||||
|
|
||||||
$subtasks = $this->client->getAllSubtasks($this->getTaskId());
|
|
||||||
$this->assertNotFalse($subtasks);
|
|
||||||
$this->assertNotEmpty($subtasks);
|
|
||||||
$this->assertTrue(is_array($subtasks));
|
|
||||||
$this->assertEquals(1, count($subtasks));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveTaskPosition()
|
|
||||||
{
|
|
||||||
$task_id = $this->getTaskId();
|
|
||||||
$this->assertTrue($this->client->moveTaskPosition(1, $task_id, 3, 1));
|
|
||||||
|
|
||||||
$task = $this->client->getTask($task_id);
|
|
||||||
$this->assertNotFalse($task);
|
|
||||||
$this->assertTrue(is_array($task));
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
$this->assertEquals(3, $task['column_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCategoryCreation()
|
|
||||||
{
|
|
||||||
$category = array(
|
|
||||||
'name' => 'Category',
|
|
||||||
'project_id' => 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
$cat_id = $this->client->execute('createCategory', $category);
|
|
||||||
$this->assertNotFalse($cat_id);
|
|
||||||
$this->assertInternalType('int', $cat_id);
|
|
||||||
$this->assertTrue($cat_id > 0);
|
|
||||||
|
|
||||||
// Duplicate
|
|
||||||
|
|
||||||
$category = array(
|
|
||||||
'name' => 'Category',
|
|
||||||
'project_id' => 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertFalse($this->client->execute('createCategory', $category));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testCategoryCreationWithBadParams()
|
|
||||||
{
|
|
||||||
// Missing project id
|
|
||||||
$category = array(
|
|
||||||
'name' => 'Category',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertNull($this->client->execute('createCategory', $category));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCategoryRead()
|
|
||||||
{
|
|
||||||
$category = $this->client->getCategory(1);
|
|
||||||
|
|
||||||
$this->assertTrue(is_array($category));
|
|
||||||
$this->assertNotEmpty($category);
|
|
||||||
$this->assertEquals(1, $category['id']);
|
|
||||||
$this->assertEquals('Category', $category['name']);
|
|
||||||
$this->assertEquals(1, $category['project_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllCategories()
|
|
||||||
{
|
|
||||||
$categories = $this->client->getAllCategories(1);
|
|
||||||
|
|
||||||
$this->assertNotEmpty($categories);
|
|
||||||
$this->assertNotFalse($categories);
|
|
||||||
$this->assertTrue(is_array($categories));
|
|
||||||
$this->assertEquals(1, count($categories));
|
|
||||||
$this->assertEquals(1, $categories[0]['id']);
|
|
||||||
$this->assertEquals('Category', $categories[0]['name']);
|
|
||||||
$this->assertEquals(1, $categories[0]['project_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCategoryUpdate()
|
|
||||||
{
|
|
||||||
$category = array(
|
|
||||||
'id' => 1,
|
|
||||||
'name' => 'Renamed category',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->execute('updateCategory', $category));
|
|
||||||
|
|
||||||
$category = $this->client->getCategory(1);
|
|
||||||
$this->assertTrue(is_array($category));
|
|
||||||
$this->assertNotEmpty($category);
|
|
||||||
$this->assertEquals(1, $category['id']);
|
|
||||||
$this->assertEquals('Renamed category', $category['name']);
|
|
||||||
$this->assertEquals(1, $category['project_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCategoryRemove()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->removeCategory(1));
|
|
||||||
$this->assertFalse($this->client->removeCategory(1));
|
|
||||||
$this->assertFalse($this->client->removeCategory(1111));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAvailableActions()
|
|
||||||
{
|
|
||||||
$actions = $this->client->getAvailableActions();
|
|
||||||
$this->assertNotEmpty($actions);
|
|
||||||
$this->assertInternalType('array', $actions);
|
|
||||||
$this->assertArrayHasKey('\Kanboard\Action\TaskCloseColumn', $actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAvailableActionEvents()
|
|
||||||
{
|
|
||||||
$events = $this->client->getAvailableActionEvents();
|
|
||||||
$this->assertNotEmpty($events);
|
|
||||||
$this->assertInternalType('array', $events);
|
|
||||||
$this->assertArrayHasKey('task.move.column', $events);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCompatibleActionEvents()
|
|
||||||
{
|
|
||||||
$events = $this->client->getCompatibleActionEvents('\Kanboard\Action\TaskCloseColumn');
|
|
||||||
$this->assertNotEmpty($events);
|
|
||||||
$this->assertInternalType('array', $events);
|
|
||||||
$this->assertArrayHasKey('task.move.column', $events);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateAction()
|
|
||||||
{
|
|
||||||
$action_id = $this->client->createAction(1, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1));
|
|
||||||
$this->assertNotFalse($action_id);
|
|
||||||
$this->assertEquals(1, $action_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetActions()
|
|
||||||
{
|
|
||||||
$actions = $this->client->getActions(1);
|
|
||||||
$this->assertNotEmpty($actions);
|
|
||||||
$this->assertInternalType('array', $actions);
|
|
||||||
$this->assertCount(1, $actions);
|
|
||||||
$this->assertArrayHasKey('id', $actions[0]);
|
|
||||||
$this->assertArrayHasKey('project_id', $actions[0]);
|
|
||||||
$this->assertArrayHasKey('event_name', $actions[0]);
|
|
||||||
$this->assertArrayHasKey('action_name', $actions[0]);
|
|
||||||
$this->assertArrayHasKey('params', $actions[0]);
|
|
||||||
$this->assertArrayHasKey('column_id', $actions[0]['params']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveAction()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->client->removeAction(1));
|
|
||||||
|
|
||||||
$actions = $this->client->getActions(1);
|
|
||||||
$this->assertEmpty($actions);
|
|
||||||
$this->assertCount(0, $actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllLinks()
|
|
||||||
{
|
|
||||||
$links = $this->client->getAllLinks();
|
|
||||||
$this->assertNotEmpty($links);
|
|
||||||
$this->assertArrayHasKey('id', $links[0]);
|
|
||||||
$this->assertArrayHasKey('label', $links[0]);
|
|
||||||
$this->assertArrayHasKey('opposite_id', $links[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetOppositeLink()
|
|
||||||
{
|
|
||||||
$link = $this->client->getOppositeLinkId(1);
|
|
||||||
$this->assertEquals(1, $link);
|
|
||||||
|
|
||||||
$link = $this->client->getOppositeLinkId(2);
|
|
||||||
$this->assertEquals(3, $link);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetLinkByLabel()
|
|
||||||
{
|
|
||||||
$link = $this->client->getLinkByLabel('blocks');
|
|
||||||
$this->assertNotEmpty($link);
|
|
||||||
$this->assertEquals(2, $link['id']);
|
|
||||||
$this->assertEquals(3, $link['opposite_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetLinkById()
|
|
||||||
{
|
|
||||||
$link = $this->client->getLinkById(4);
|
|
||||||
$this->assertNotEmpty($link);
|
|
||||||
$this->assertEquals(4, $link['id']);
|
|
||||||
$this->assertEquals(5, $link['opposite_id']);
|
|
||||||
$this->assertEquals('duplicates', $link['label']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateLink()
|
|
||||||
{
|
|
||||||
$link_id = $this->client->createLink(array('label' => 'test'));
|
|
||||||
$this->assertNotFalse($link_id);
|
|
||||||
$this->assertInternalType('int', $link_id);
|
|
||||||
|
|
||||||
$link_id = $this->client->createLink(array('label' => 'foo', 'opposite_label' => 'bar'));
|
|
||||||
$this->assertNotFalse($link_id);
|
|
||||||
$this->assertInternalType('int', $link_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateLink()
|
|
||||||
{
|
|
||||||
$link1 = $this->client->getLinkByLabel('bar');
|
|
||||||
$this->assertNotEmpty($link1);
|
|
||||||
|
|
||||||
$link2 = $this->client->getLinkByLabel('test');
|
|
||||||
$this->assertNotEmpty($link2);
|
|
||||||
|
|
||||||
$this->assertNotFalse($this->client->updateLink($link1['id'], $link2['id'], 'boo'));
|
|
||||||
|
|
||||||
$link = $this->client->getLinkById($link1['id']);
|
|
||||||
$this->assertNotEmpty($link);
|
|
||||||
$this->assertEquals($link2['id'], $link['opposite_id']);
|
|
||||||
$this->assertEquals('boo', $link['label']);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->removeLink($link1['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateTaskLink()
|
|
||||||
{
|
|
||||||
$task_id1 = $this->client->createTask(array('project_id' => 1, 'title' => 'A'));
|
|
||||||
$this->assertNotFalse($task_id1);
|
|
||||||
|
|
||||||
$task_id2 = $this->client->createTask(array('project_id' => 1, 'title' => 'B'));
|
|
||||||
$this->assertNotFalse($task_id2);
|
|
||||||
|
|
||||||
$task_id3 = $this->client->createTask(array('project_id' => 1, 'title' => 'C'));
|
|
||||||
$this->assertNotFalse($task_id3);
|
|
||||||
|
|
||||||
$task_link_id = $this->client->createTaskLink($task_id1, $task_id2, 1);
|
|
||||||
$this->assertNotFalse($task_link_id);
|
|
||||||
|
|
||||||
$task_link = $this->client->getTaskLinkById($task_link_id);
|
|
||||||
$this->assertNotEmpty($task_link);
|
|
||||||
$this->assertEquals($task_id1, $task_link['task_id']);
|
|
||||||
$this->assertEquals($task_id2, $task_link['opposite_task_id']);
|
|
||||||
$this->assertEquals(1, $task_link['link_id']);
|
|
||||||
|
|
||||||
$task_links = $this->client->getAllTaskLinks($task_id1);
|
|
||||||
$this->assertNotEmpty($task_links);
|
|
||||||
$this->assertCount(1, $task_links);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->updateTaskLink($task_link_id, $task_id1, $task_id3, 2));
|
|
||||||
|
|
||||||
$task_link = $this->client->getTaskLinkById($task_link_id);
|
|
||||||
$this->assertNotEmpty($task_link);
|
|
||||||
$this->assertEquals($task_id1, $task_link['task_id']);
|
|
||||||
$this->assertEquals($task_id3, $task_link['opposite_task_id']);
|
|
||||||
$this->assertEquals(2, $task_link['link_id']);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->removeTaskLink($task_link_id));
|
|
||||||
$this->assertEmpty($this->client->getAllTaskLinks($task_id1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateFile()
|
|
||||||
{
|
|
||||||
$this->assertNotFalse($this->client->createFile(1, $this->getTaskId(), 'My file', base64_encode('plain text file')));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllFiles()
|
|
||||||
{
|
|
||||||
$files = $this->client->getAllFiles(array('task_id' => $this->getTaskId()));
|
|
||||||
|
|
||||||
$this->assertNotEmpty($files);
|
|
||||||
$this->assertCount(1, $files);
|
|
||||||
$this->assertEquals('My file', $files[0]['name']);
|
|
||||||
|
|
||||||
$file = $this->client->getFile($files[0]['id']);
|
|
||||||
$this->assertNotEmpty($file);
|
|
||||||
$this->assertEquals('My file', $file['name']);
|
|
||||||
|
|
||||||
$content = $this->client->downloadFile($file['id']);
|
|
||||||
$this->assertNotEmpty($content);
|
|
||||||
$this->assertEquals('plain text file', base64_decode($content));
|
|
||||||
|
|
||||||
$content = $this->client->downloadFile(1234567);
|
|
||||||
$this->assertEmpty($content);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->removeFile($file['id']));
|
|
||||||
$this->assertEmpty($this->client->getAllFiles(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveAllFiles()
|
|
||||||
{
|
|
||||||
$this->assertNotFalse($this->client->createFile(1, $this->getTaskId(), 'My file 1', base64_encode('plain text file')));
|
|
||||||
$this->assertNotFalse($this->client->createFile(1, $this->getTaskId(), 'My file 2', base64_encode('plain text file')));
|
|
||||||
|
|
||||||
$files = $this->client->getAllFiles(array('task_id' => $this->getTaskId()));
|
|
||||||
$this->assertNotEmpty($files);
|
|
||||||
$this->assertCount(2, $files);
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->removeAllFiles(array('task_id' => $this->getTaskId())));
|
|
||||||
|
|
||||||
$files = $this->client->getAllFiles(array('task_id' => $this->getTaskId()));
|
|
||||||
$this->assertEmpty($files);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateTaskWithReference()
|
|
||||||
{
|
|
||||||
$task = array(
|
|
||||||
'title' => 'Task with external ticket number',
|
|
||||||
'reference' => 'TICKET-1234',
|
|
||||||
'project_id' => 1,
|
|
||||||
'description' => '[Link to my ticket](http://my-ticketing-system/1234)',
|
|
||||||
);
|
|
||||||
|
|
||||||
$task_id = $this->client->createTask($task);
|
|
||||||
|
|
||||||
$this->assertNotFalse($task_id);
|
|
||||||
$this->assertInternalType('int', $task_id);
|
|
||||||
$this->assertTrue($task_id > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetTaskByReference()
|
|
||||||
{
|
|
||||||
$task = $this->client->getTaskByReference(array('project_id' => 1, 'reference' => 'TICKET-1234'));
|
|
||||||
|
|
||||||
$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=TaskViewController&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateOverdueTask()
|
|
||||||
{
|
|
||||||
$this->assertNotFalse($this->client->createTask(array(
|
|
||||||
'title' => 'overdue task',
|
|
||||||
'project_id' => 1,
|
|
||||||
'date_due' => date('Y-m-d', strtotime('-2days')),
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetOverdueTasksByProject()
|
|
||||||
{
|
|
||||||
$tasks = $this->client->getOverdueTasksByProject(1);
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
|
||||||
$this->assertEquals('API test', $tasks[0]['project_name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetOverdueTasks()
|
|
||||||
{
|
|
||||||
$tasks = $this->client->getOverdueTasks();
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
|
||||||
$this->assertEquals('API test', $tasks[0]['project_name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class AppTest extends Base
|
class AppTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testGetTimezone()
|
public function testGetTimezone()
|
||||||
{
|
{
|
||||||
|
|
@ -31,4 +31,24 @@ class AppTest extends Base
|
||||||
$this->assertEquals('Project Member', $roles['project-member']);
|
$this->assertEquals('Project Member', $roles['project-member']);
|
||||||
$this->assertEquals('Project Viewer', $roles['project-viewer']);
|
$this->assertEquals('Project Viewer', $roles['project-viewer']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetDefaultColor()
|
||||||
|
{
|
||||||
|
$this->assertEquals('yellow', $this->user->getDefaultTaskColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDefaultColors()
|
||||||
|
{
|
||||||
|
$colors = $this->user->getDefaultTaskColors();
|
||||||
|
$this->assertNotEmpty($colors);
|
||||||
|
$this->assertArrayHasKey('red', $colors);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetColorList()
|
||||||
|
{
|
||||||
|
$colors = $this->user->getColorList();
|
||||||
|
$this->assertNotEmpty($colors);
|
||||||
|
$this->assertArrayHasKey('red', $colors);
|
||||||
|
$this->assertEquals('Red', $colors['red']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__.'/../../vendor/autoload.php';
|
|
||||||
|
|
||||||
abstract class Base extends PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
protected $app = null;
|
|
||||||
protected $admin = null;
|
|
||||||
protected $user = null;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (DB_DRIVER === 'sqlite') {
|
|
||||||
@unlink(DB_FILENAME);
|
|
||||||
} elseif (DB_DRIVER === 'mysql') {
|
|
||||||
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
|
||||||
$pdo->exec('DROP DATABASE '.DB_NAME);
|
|
||||||
$pdo->exec('CREATE DATABASE '.DB_NAME);
|
|
||||||
$pdo = null;
|
|
||||||
} elseif (DB_DRIVER === 'postgres') {
|
|
||||||
$pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
|
||||||
$pdo->exec('DROP DATABASE '.DB_NAME);
|
|
||||||
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
|
|
||||||
$pdo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$service = new Kanboard\ServiceProvider\DatabaseProvider;
|
|
||||||
|
|
||||||
$db = $service->getInstance();
|
|
||||||
$db->table('settings')->eq('option', 'api_token')->update(array('value' => API_KEY));
|
|
||||||
$db->closeConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->app = new JsonRPC\Client(API_URL);
|
|
||||||
$this->app->authentication('jsonrpc', API_KEY);
|
|
||||||
$this->app->getHttpClient()->withDebug();
|
|
||||||
|
|
||||||
$this->admin = new JsonRPC\Client(API_URL);
|
|
||||||
$this->admin->authentication('admin', 'admin');
|
|
||||||
$this->admin->getHttpClient()->withDebug();
|
|
||||||
|
|
||||||
$this->user = new JsonRPC\Client(API_URL);
|
|
||||||
$this->user->authentication('user', 'password');
|
|
||||||
$this->user->getHttpClient()->withDebug();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getProjectId()
|
|
||||||
{
|
|
||||||
$projects = $this->app->getAllProjects();
|
|
||||||
$this->assertNotEmpty($projects);
|
|
||||||
return $projects[0]['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getGroupId()
|
|
||||||
{
|
|
||||||
$groups = $this->app->getAllGroups();
|
|
||||||
$this->assertNotEmpty($groups);
|
|
||||||
return $groups[0]['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
abstract class BaseIntegrationTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected $app = null;
|
||||||
|
protected $admin = null;
|
||||||
|
protected $manager = null;
|
||||||
|
protected $user = null;
|
||||||
|
|
||||||
|
protected $adminUserId = 0;
|
||||||
|
protected $managerUserId = 0;
|
||||||
|
protected $userUserId = 0;
|
||||||
|
|
||||||
|
protected $projectName = '';
|
||||||
|
protected $projectId = 0;
|
||||||
|
protected $taskTitle = 'My task';
|
||||||
|
protected $taskId = 0;
|
||||||
|
|
||||||
|
protected $groupName1 = 'My Group A';
|
||||||
|
protected $groupName2 = 'My Group B';
|
||||||
|
protected $groupId1;
|
||||||
|
protected $groupId2;
|
||||||
|
|
||||||
|
protected $username = 'test-user';
|
||||||
|
protected $userId;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->setUpAppClient();
|
||||||
|
$this->setUpAdminUser();
|
||||||
|
$this->setUpManagerUser();
|
||||||
|
$this->setUpStandardUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpAppClient()
|
||||||
|
{
|
||||||
|
$this->app = new JsonRPC\Client(API_URL);
|
||||||
|
$this->app->authentication('jsonrpc', API_KEY);
|
||||||
|
$this->app->getHttpClient()->withDebug()->withTimeout(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpAdminUser()
|
||||||
|
{
|
||||||
|
$this->adminUserId = $this->getUserId('superuser');
|
||||||
|
|
||||||
|
if (! $this->adminUserId) {
|
||||||
|
$this->adminUserId = $this->app->createUser('superuser', 'password', 'Admin User', 'user@localhost', 'app-admin');
|
||||||
|
$this->assertNotFalse($this->adminUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->admin = new JsonRPC\Client(API_URL);
|
||||||
|
$this->admin->authentication('superuser', 'password');
|
||||||
|
$this->admin->getHttpClient()->withDebug();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpManagerUser()
|
||||||
|
{
|
||||||
|
$this->managerUserId = $this->getUserId('manager');
|
||||||
|
|
||||||
|
if (! $this->managerUserId) {
|
||||||
|
$this->managerUserId = $this->app->createUser('manager', 'password', 'Manager User', 'user@localhost', 'app-manager');
|
||||||
|
$this->assertNotFalse($this->managerUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->manager = new JsonRPC\Client(API_URL);
|
||||||
|
$this->manager->authentication('manager', 'password');
|
||||||
|
$this->manager->getHttpClient()->withDebug();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpStandardUser()
|
||||||
|
{
|
||||||
|
$this->userUserId = $this->getUserId('user');
|
||||||
|
|
||||||
|
if (! $this->userUserId) {
|
||||||
|
$this->userUserId = $this->app->createUser('user', 'password', 'Standard User', 'user@localhost', 'app-user');
|
||||||
|
$this->assertNotFalse($this->userUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user = new JsonRPC\Client(API_URL);
|
||||||
|
$this->user->authentication('user', 'password');
|
||||||
|
$this->user->getHttpClient()->withDebug();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserId($username)
|
||||||
|
{
|
||||||
|
$user = $this->app->getUserByName($username);
|
||||||
|
|
||||||
|
if (! empty($user)) {
|
||||||
|
return $user['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateTeamProject()
|
||||||
|
{
|
||||||
|
$this->projectId = $this->app->createProject($this->projectName, 'Description');
|
||||||
|
$this->assertNotFalse($this->projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateUser()
|
||||||
|
{
|
||||||
|
$this->userId = $this->app->createUser($this->username, 'password');
|
||||||
|
$this->assertNotFalse($this->userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateGroups()
|
||||||
|
{
|
||||||
|
$this->groupId1 = $this->app->createGroup($this->groupName1);
|
||||||
|
$this->groupId2 = $this->app->createGroup($this->groupName2, 'External ID');
|
||||||
|
$this->assertNotFalse($this->groupId1);
|
||||||
|
$this->assertNotFalse($this->groupId2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateTask()
|
||||||
|
{
|
||||||
|
$this->taskId = $this->app->createTask(array('title' => $this->taskTitle, 'project_id' => $this->projectId));
|
||||||
|
$this->assertNotFalse($this->taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class BoardTest extends Base
|
class BoardTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testCreateProject()
|
protected $projectName = 'My project to test board';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertEquals(1, $this->app->createProject('A project'));
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertGetBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetBoard()
|
public function assertGetBoard()
|
||||||
{
|
{
|
||||||
$board = $this->app->getBoard(1);
|
$board = $this->app->getBoard($this->projectId);
|
||||||
|
$this->assertNotNull($board);
|
||||||
$this->assertCount(1, $board);
|
$this->assertCount(1, $board);
|
||||||
$this->assertEquals('Default swimlane', $board[0]['name']);
|
$this->assertEquals('Default swimlane', $board[0]['name']);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class CategoryTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test categories';
|
||||||
|
private $categoryId = 0;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateCategory();
|
||||||
|
$this->assertThatCategoriesAreUnique();
|
||||||
|
$this->assertGetCategory();
|
||||||
|
$this->assertGetAllCategories();
|
||||||
|
$this->assertCategoryUpdate();
|
||||||
|
$this->assertRemoveCategory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateCategory()
|
||||||
|
{
|
||||||
|
$this->categoryId = $this->app->createCategory(array(
|
||||||
|
'name' => 'Category',
|
||||||
|
'project_id' => $this->projectId,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertNotFalse($this->categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertThatCategoriesAreUnique()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->app->execute('createCategory', array(
|
||||||
|
'name' => 'Category',
|
||||||
|
'project_id' => $this->projectId,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetCategory()
|
||||||
|
{
|
||||||
|
$category = $this->app->getCategory($this->categoryId);
|
||||||
|
|
||||||
|
$this->assertInternalType('array', $category);
|
||||||
|
$this->assertEquals($this->categoryId, $category['id']);
|
||||||
|
$this->assertEquals('Category', $category['name']);
|
||||||
|
$this->assertEquals($this->projectId, $category['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllCategories()
|
||||||
|
{
|
||||||
|
$categories = $this->app->getAllCategories($this->projectId);
|
||||||
|
|
||||||
|
$this->assertCount(1, $categories);
|
||||||
|
$this->assertEquals($this->categoryId, $categories[0]['id']);
|
||||||
|
$this->assertEquals('Category', $categories[0]['name']);
|
||||||
|
$this->assertEquals($this->projectId, $categories[0]['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCategoryUpdate()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->execute('updateCategory', array(
|
||||||
|
'id' => $this->categoryId,
|
||||||
|
'name' => 'Renamed category',
|
||||||
|
)));
|
||||||
|
|
||||||
|
$category = $this->app->getCategory($this->categoryId);
|
||||||
|
$this->assertEquals('Renamed category', $category['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveCategory()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeCategory($this->categoryId));
|
||||||
|
$this->assertFalse($this->app->removeCategory($this->categoryId));
|
||||||
|
$this->assertFalse($this->app->removeCategory(1111));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,65 +1,69 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class ColumnTest extends Base
|
class ColumnTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testCreateProject()
|
protected $projectName = 'My project to test columns';
|
||||||
|
private $columns = array();
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertEquals(1, $this->app->createProject('A project'));
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertGetColumns();
|
||||||
|
$this->assertUpdateColumn();
|
||||||
|
$this->assertAddColumn();
|
||||||
|
$this->assertRemoveColumn();
|
||||||
|
$this->assertChangeColumnPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetColumns()
|
public function assertGetColumns()
|
||||||
{
|
{
|
||||||
$columns = $this->app->getColumns($this->getProjectId());
|
$this->columns = $this->app->getColumns($this->projectId);
|
||||||
$this->assertCount(4, $columns);
|
$this->assertCount(4, $this->columns);
|
||||||
$this->assertEquals('Done', $columns[3]['title']);
|
$this->assertEquals('Done', $this->columns[3]['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateColumn()
|
public function assertUpdateColumn()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->updateColumn(4, 'Boo', 2));
|
$this->assertTrue($this->app->updateColumn($this->columns[3]['id'], 'Another column', 2));
|
||||||
|
|
||||||
$columns = $this->app->getColumns($this->getProjectId());
|
$this->columns = $this->app->getColumns($this->projectId);
|
||||||
$this->assertEquals('Boo', $columns[3]['title']);
|
$this->assertEquals('Another column', $this->columns[3]['title']);
|
||||||
$this->assertEquals(2, $columns[3]['task_limit']);
|
$this->assertEquals(2, $this->columns[3]['task_limit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddColumn()
|
public function assertAddColumn()
|
||||||
{
|
{
|
||||||
$column_id = $this->app->addColumn($this->getProjectId(), 'New column');
|
$column_id = $this->app->addColumn($this->projectId, 'New column');
|
||||||
|
|
||||||
$this->assertNotFalse($column_id);
|
$this->assertNotFalse($column_id);
|
||||||
$this->assertInternalType('int', $column_id);
|
|
||||||
$this->assertTrue($column_id > 0);
|
$this->assertTrue($column_id > 0);
|
||||||
|
|
||||||
$columns = $this->app->getColumns($this->getProjectId());
|
$this->columns = $this->app->getColumns($this->projectId);
|
||||||
$this->assertCount(5, $columns);
|
$this->assertCount(5, $this->columns);
|
||||||
$this->assertEquals('New column', $columns[4]['title']);
|
$this->assertEquals('New column', $this->columns[4]['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemoveColumn()
|
public function assertRemoveColumn()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->removeColumn(5));
|
$this->assertTrue($this->app->removeColumn($this->columns[3]['id']));
|
||||||
|
|
||||||
$columns = $this->app->getColumns($this->getProjectId());
|
$this->columns = $this->app->getColumns($this->projectId);
|
||||||
$this->assertCount(4, $columns);
|
$this->assertCount(4, $this->columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeColumnPosition()
|
public function assertChangeColumnPosition()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->changeColumnPosition($this->getProjectId(), 1, 3));
|
$this->assertTrue($this->app->changeColumnPosition($this->projectId, $this->columns[0]['id'], 3));
|
||||||
|
|
||||||
$columns = $this->app->getColumns($this->getProjectId());
|
$this->columns = $this->app->getColumns($this->projectId);
|
||||||
$this->assertCount(4, $columns);
|
$this->assertEquals('Ready', $this->columns[0]['title']);
|
||||||
|
$this->assertEquals(1, $this->columns[0]['position']);
|
||||||
$this->assertEquals('Ready', $columns[0]['title']);
|
$this->assertEquals('Work in progress', $this->columns[1]['title']);
|
||||||
$this->assertEquals(1, $columns[0]['position']);
|
$this->assertEquals(2, $this->columns[1]['position']);
|
||||||
$this->assertEquals('Work in progress', $columns[1]['title']);
|
$this->assertEquals('Backlog', $this->columns[2]['title']);
|
||||||
$this->assertEquals(2, $columns[1]['position']);
|
$this->assertEquals(3, $this->columns[2]['position']);
|
||||||
$this->assertEquals('Backlog', $columns[2]['title']);
|
$this->assertEquals('New column', $this->columns[3]['title']);
|
||||||
$this->assertEquals(3, $columns[2]['position']);
|
$this->assertEquals(4, $this->columns[3]['position']);
|
||||||
$this->assertEquals('Boo', $columns[3]['title']);
|
|
||||||
$this->assertEquals(4, $columns[3]['position']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class CommentTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test comments';
|
||||||
|
private $commentId = 0;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateTask();
|
||||||
|
$this->assertCreateComment();
|
||||||
|
$this->assertUpdateComment();
|
||||||
|
$this->assertGetAllComments();
|
||||||
|
$this->assertRemoveComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateComment()
|
||||||
|
{
|
||||||
|
$this->commentId = $this->app->execute('createComment', array(
|
||||||
|
'task_id' => $this->taskId,
|
||||||
|
'user_id' => 1,
|
||||||
|
'content' => 'foobar',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertNotFalse($this->commentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetComment()
|
||||||
|
{
|
||||||
|
$comment = $this->app->getComment($this->commentId);
|
||||||
|
$this->assertNotFalse($comment);
|
||||||
|
$this->assertNotEmpty($comment);
|
||||||
|
$this->assertEquals(1, $comment['user_id']);
|
||||||
|
$this->assertEquals('foobar', $comment['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertUpdateComment()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->execute('updateComment', array(
|
||||||
|
'id' => $this->commentId,
|
||||||
|
'content' => 'test',
|
||||||
|
)));
|
||||||
|
|
||||||
|
$comment = $this->app->getComment($this->commentId);
|
||||||
|
$this->assertEquals('test', $comment['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllComments()
|
||||||
|
{
|
||||||
|
$comments = $this->app->getAllComments($this->taskId);
|
||||||
|
$this->assertCount(1, $comments);
|
||||||
|
$this->assertEquals('test', $comments[0]['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveComment()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeComment($this->commentId));
|
||||||
|
$this->assertFalse($this->app->removeComment($this->commentId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,47 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class GroupMemberTest extends Base
|
class GroupMemberTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testAddMember()
|
protected $username = 'user-group-member';
|
||||||
{
|
protected $groupName1 = 'My group member A';
|
||||||
$this->assertNotFalse($this->app->createGroup('My Group A'));
|
protected $groupName2 = 'My group member B';
|
||||||
$this->assertNotFalse($this->app->createGroup('My Group B'));
|
|
||||||
|
|
||||||
$groupId = $this->getGroupId();
|
public function testAll()
|
||||||
$this->assertTrue($this->app->addGroupMember($groupId, 1));
|
{
|
||||||
|
$this->assertCreateGroups();
|
||||||
|
$this->assertCreateUser();
|
||||||
|
$this->assertAddMember();
|
||||||
|
$this->assertGetMembers();
|
||||||
|
$this->assertIsGroupMember();
|
||||||
|
$this->assertGetGroups();
|
||||||
|
$this->assertRemove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetMembers()
|
public function assertAddMember()
|
||||||
{
|
{
|
||||||
$groups = $this->app->getAllGroups();
|
$this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId));
|
||||||
$members = $this->app->getGroupMembers($groups[0]['id']);
|
}
|
||||||
|
|
||||||
|
public function assertGetMembers()
|
||||||
|
{
|
||||||
|
$members = $this->app->getGroupMembers($this->groupId1);
|
||||||
$this->assertCount(1, $members);
|
$this->assertCount(1, $members);
|
||||||
$this->assertEquals('admin', $members[0]['username']);
|
$this->assertEquals($this->username, $members[0]['username']);
|
||||||
|
|
||||||
$this->assertSame(array(), $this->app->getGroupMembers($groups[1]['id']));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsGroupMember()
|
public function assertIsGroupMember()
|
||||||
{
|
{
|
||||||
$groupId = $this->getGroupId();
|
$this->assertTrue($this->app->isGroupMember($this->groupId1, $this->userId));
|
||||||
$this->assertTrue($this->app->isGroupMember($groupId, 1));
|
$this->assertFalse($this->app->isGroupMember($this->groupId1, $this->adminUserId));
|
||||||
$this->assertFalse($this->app->isGroupMember($groupId, 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetGroups()
|
public function assertGetGroups()
|
||||||
{
|
{
|
||||||
$groups = $this->app->getMemberGroups(1);
|
$groups = $this->app->getMemberGroups($this->userId);
|
||||||
$this->assertCount(1, $groups);
|
$this->assertCount(1, $groups);
|
||||||
$this->assertEquals(1, $groups[0]['id']);
|
$this->assertEquals($this->groupId1, $groups[0]['id']);
|
||||||
$this->assertEquals('My Group A', $groups[0]['name']);
|
$this->assertEquals($this->groupName1, $groups[0]['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function assertRemove()
|
||||||
{
|
{
|
||||||
$groupId = $this->getGroupId();
|
$this->assertTrue($this->app->removeGroupMember($this->groupId1, $this->userId));
|
||||||
$this->assertTrue($this->app->removeGroupMember($groupId, 1));
|
$this->assertFalse($this->app->isGroupMember($this->groupId1, $this->userId));
|
||||||
$this->assertFalse($this->app->isGroupMember($groupId, 1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,50 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class GroupTest extends Base
|
class GroupTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testCreateGroup()
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertNotFalse($this->app->createGroup('My Group A'));
|
$this->assertCreateGroups();
|
||||||
$this->assertNotFalse($this->app->createGroup('My Group B', '1234'));
|
$this->assertGetAllGroups();
|
||||||
|
$this->assertGetGroup();
|
||||||
|
$this->assertUpdateGroup();
|
||||||
|
$this->assertRemove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetter()
|
public function assertGetAllGroups()
|
||||||
{
|
{
|
||||||
$groups = $this->app->getAllGroups();
|
$groups = $this->app->getAllGroups();
|
||||||
$this->assertCount(2, $groups);
|
$this->assertNotEmpty($groups);
|
||||||
$this->assertEquals('My Group A', $groups[0]['name']);
|
$this->assertArrayHasKey('name', $groups[0]);
|
||||||
$this->assertEquals('', $groups[0]['external_id']);
|
$this->assertArrayHasKey('external_id', $groups[0]);
|
||||||
$this->assertEquals('My Group B', $groups[1]['name']);
|
}
|
||||||
$this->assertEquals('1234', $groups[1]['external_id']);
|
|
||||||
|
|
||||||
$group = $this->app->getGroup($groups[0]['id']);
|
public function assertGetGroup()
|
||||||
|
{
|
||||||
|
$group = $this->app->getGroup($this->groupId1);
|
||||||
$this->assertNotEmpty($group);
|
$this->assertNotEmpty($group);
|
||||||
$this->assertEquals('My Group A', $group['name']);
|
$this->assertEquals($this->groupName1, $group['name']);
|
||||||
$this->assertEquals('', $group['external_id']);
|
$this->assertEquals('', $group['external_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdate()
|
public function assertUpdateGroup()
|
||||||
{
|
{
|
||||||
$groups = $this->app->getAllGroups();
|
$this->assertTrue($this->app->updateGroup(array(
|
||||||
|
'group_id' => $this->groupId2,
|
||||||
|
'name' => 'My Group C',
|
||||||
|
'external_id' => 'something else',
|
||||||
|
)));
|
||||||
|
|
||||||
$this->assertTrue($this->app->updateGroup(array('group_id' => $groups[0]['id'], 'name' => 'ABC', 'external_id' => 'something')));
|
$group = $this->app->getGroup($this->groupId2);
|
||||||
$this->assertTrue($this->app->updateGroup(array('group_id' => $groups[1]['id'], 'external_id' => '')));
|
$this->assertNotEmpty($group);
|
||||||
|
$this->assertEquals('My Group C', $group['name']);
|
||||||
$groups = $this->app->getAllGroups();
|
$this->assertEquals('something else', $group['external_id']);
|
||||||
$this->assertEquals('ABC', $groups[0]['name']);
|
|
||||||
$this->assertEquals('something', $groups[0]['external_id']);
|
|
||||||
$this->assertEquals('', $groups[1]['external_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function assertRemove()
|
||||||
{
|
{
|
||||||
$groups = $this->app->getAllGroups();
|
$this->assertTrue($this->app->removeGroup($this->groupId1));
|
||||||
$this->assertTrue($this->app->removeGroup($groups[0]['id']));
|
|
||||||
$this->assertTrue($this->app->removeGroup($groups[1]['id']));
|
|
||||||
$this->assertSame(array(), $this->app->getAllGroups());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class LinkTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
public function testGetAllLinks()
|
||||||
|
{
|
||||||
|
$links = $this->app->getAllLinks();
|
||||||
|
$this->assertNotEmpty($links);
|
||||||
|
$this->assertArrayHasKey('id', $links[0]);
|
||||||
|
$this->assertArrayHasKey('label', $links[0]);
|
||||||
|
$this->assertArrayHasKey('opposite_id', $links[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetOppositeLink()
|
||||||
|
{
|
||||||
|
$link = $this->app->getOppositeLinkId(1);
|
||||||
|
$this->assertEquals(1, $link);
|
||||||
|
|
||||||
|
$link = $this->app->getOppositeLinkId(2);
|
||||||
|
$this->assertEquals(3, $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkByLabel()
|
||||||
|
{
|
||||||
|
$link = $this->app->getLinkByLabel('blocks');
|
||||||
|
$this->assertNotEmpty($link);
|
||||||
|
$this->assertEquals(2, $link['id']);
|
||||||
|
$this->assertEquals(3, $link['opposite_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkById()
|
||||||
|
{
|
||||||
|
$link = $this->app->getLinkById(4);
|
||||||
|
$this->assertNotEmpty($link);
|
||||||
|
$this->assertEquals(4, $link['id']);
|
||||||
|
$this->assertEquals(5, $link['opposite_id']);
|
||||||
|
$this->assertEquals('duplicates', $link['label']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreateLink()
|
||||||
|
{
|
||||||
|
$link_id = $this->app->createLink(array('label' => 'test'));
|
||||||
|
$this->assertNotFalse($link_id);
|
||||||
|
$this->assertInternalType('int', $link_id);
|
||||||
|
|
||||||
|
$link_id = $this->app->createLink(array('label' => 'foo', 'opposite_label' => 'bar'));
|
||||||
|
$this->assertNotFalse($link_id);
|
||||||
|
$this->assertInternalType('int', $link_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpdateLink()
|
||||||
|
{
|
||||||
|
$link1 = $this->app->getLinkByLabel('bar');
|
||||||
|
$this->assertNotEmpty($link1);
|
||||||
|
|
||||||
|
$link2 = $this->app->getLinkByLabel('test');
|
||||||
|
$this->assertNotEmpty($link2);
|
||||||
|
|
||||||
|
$this->assertNotFalse($this->app->updateLink($link1['id'], $link2['id'], 'my link'));
|
||||||
|
|
||||||
|
$link = $this->app->getLinkById($link1['id']);
|
||||||
|
$this->assertNotEmpty($link);
|
||||||
|
$this->assertEquals($link2['id'], $link['opposite_id']);
|
||||||
|
$this->assertEquals('my link', $link['label']);
|
||||||
|
|
||||||
|
$this->assertTrue($this->app->removeLink($link1['id']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,207 +1,60 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class MeTest extends Base
|
class MeTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testCreateProject()
|
protected $projectName = 'My private project';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertEquals(1, $this->app->createProject('team project'));
|
$this->assertGetMe();
|
||||||
|
$this->assertCreateMyPrivateProject();
|
||||||
|
$this->assertGetMyProjectsList();
|
||||||
|
$this->assertGetMyProjects();
|
||||||
|
$this->assertCreateTask();
|
||||||
|
$this->assertGetMyDashboard();
|
||||||
|
$this->assertGetMyActivityStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateUser()
|
public function assertGetMe()
|
||||||
{
|
|
||||||
$this->assertEquals(2, $this->app->createUser('user', 'password'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException JsonRPC\Exception\AccessDeniedException
|
|
||||||
*/
|
|
||||||
public function testNotAllowedAppProcedure()
|
|
||||||
{
|
|
||||||
$this->app->getMe();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException JsonRPC\Exception\AccessDeniedException
|
|
||||||
*/
|
|
||||||
public function testNotAllowedUserProcedure()
|
|
||||||
{
|
|
||||||
$this->user->getAllProjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException JsonRPC\Exception\AccessDeniedException
|
|
||||||
*/
|
|
||||||
public function testNotAllowedProjectForUser()
|
|
||||||
{
|
|
||||||
$this->user->getProjectById(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAllowedProjectForAdmin()
|
|
||||||
{
|
|
||||||
$this->assertNotEmpty($this->admin->getProjectById(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetTimezone()
|
|
||||||
{
|
|
||||||
$this->assertEquals('UTC', $this->user->getTimezone());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetVersion()
|
|
||||||
{
|
|
||||||
$this->assertEquals('master', $this->user->getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetDefaultColor()
|
|
||||||
{
|
|
||||||
$this->assertEquals('yellow', $this->user->getDefaultTaskColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetDefaultColors()
|
|
||||||
{
|
|
||||||
$colors = $this->user->getDefaultTaskColors();
|
|
||||||
$this->assertNotEmpty($colors);
|
|
||||||
$this->assertArrayHasKey('red', $colors);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetColorList()
|
|
||||||
{
|
|
||||||
$colors = $this->user->getColorList();
|
|
||||||
$this->assertNotEmpty($colors);
|
|
||||||
$this->assertArrayHasKey('red', $colors);
|
|
||||||
$this->assertEquals('Red', $colors['red']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMe()
|
|
||||||
{
|
{
|
||||||
$profile = $this->user->getMe();
|
$profile = $this->user->getMe();
|
||||||
$this->assertNotEmpty($profile);
|
|
||||||
$this->assertEquals(2, $profile['id']);
|
|
||||||
$this->assertEquals('user', $profile['username']);
|
$this->assertEquals('user', $profile['username']);
|
||||||
|
$this->assertEquals('app-user', $profile['role']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateMyPrivateProject()
|
public function assertCreateMyPrivateProject()
|
||||||
{
|
{
|
||||||
$this->assertEquals(2, $this->user->createMyPrivateProject('my project'));
|
$this->projectId = $this->user->createMyPrivateProject($this->projectName);
|
||||||
|
$this->assertNotFalse($this->projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetMyProjectsList()
|
public function assertGetMyProjectsList()
|
||||||
{
|
{
|
||||||
$projects = $this->user->getMyProjectsList();
|
$projects = $this->user->getMyProjectsList();
|
||||||
$this->assertNotEmpty($projects);
|
$this->assertNotEmpty($projects);
|
||||||
$this->assertArrayNotHasKey(1, $projects);
|
$this->assertEquals($this->projectName, $projects[$this->projectId]);
|
||||||
$this->assertArrayHasKey(2, $projects);
|
|
||||||
$this->assertEquals('my project', $projects[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetMyProjects()
|
public function assertGetMyProjects()
|
||||||
{
|
{
|
||||||
$projects = $this->user->getMyProjects();
|
$projects = $this->user->getMyProjects();
|
||||||
$this->assertNotEmpty($projects);
|
$this->assertNotEmpty($projects);
|
||||||
$this->assertCount(1, $projects);
|
$this->assertCount(1, $projects);
|
||||||
$this->assertEquals(2, $projects[0]['id']);
|
$this->assertEquals($this->projectName, $projects[0]['name']);
|
||||||
$this->assertEquals('my project', $projects[0]['name']);
|
|
||||||
$this->assertNotEmpty($projects[0]['url']['calendar']);
|
$this->assertNotEmpty($projects[0]['url']['calendar']);
|
||||||
$this->assertNotEmpty($projects[0]['url']['board']);
|
$this->assertNotEmpty($projects[0]['url']['board']);
|
||||||
$this->assertNotEmpty($projects[0]['url']['list']);
|
$this->assertNotEmpty($projects[0]['url']['list']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetProjectById()
|
public function assertCreateTask()
|
||||||
{
|
{
|
||||||
$project = $this->user->getProjectById(2);
|
$taskId = $this->user->createTask(array('title' => 'My task', 'project_id' => $this->projectId, 'owner_id' => $this->userUserId));
|
||||||
$this->assertNotEmpty($project);
|
$this->assertNotFalse($taskId);
|
||||||
$this->assertEquals('my project', $project['name']);
|
|
||||||
$this->assertEquals(1, $project['is_private']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateTask()
|
public function assertGetMyDashboard()
|
||||||
{
|
|
||||||
$this->assertEquals(1, $this->user->createTask('my user title', 2));
|
|
||||||
$this->assertEquals(2, $this->admin->createTask('my admin title', 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateTaskWithWrongMember()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->user->createTask(array('title' => 'something', 'project_id' => 2, 'owner_id' => 1)));
|
|
||||||
$this->assertFalse($this->app->createTask(array('title' => 'something', 'project_id' => 1, 'owner_id' => 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetTask()
|
|
||||||
{
|
|
||||||
$task = $this->user->getTask(1);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals('my user title', $task['title']);
|
|
||||||
$this->assertEquals('yellow', $task['color_id']);
|
|
||||||
$this->assertArrayHasKey('color', $task);
|
|
||||||
$this->assertArrayHasKey('name', $task['color']);
|
|
||||||
$this->assertArrayHasKey('border', $task['color']);
|
|
||||||
$this->assertArrayHasKey('background', $task['color']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException JsonRPC\Exception\AccessDeniedException
|
|
||||||
*/
|
|
||||||
public function testGetAdminTask()
|
|
||||||
{
|
|
||||||
$this->user->getTask(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException JsonRPC\Exception\AccessDeniedException
|
|
||||||
*/
|
|
||||||
public function testGetProjectActivityDenied()
|
|
||||||
{
|
|
||||||
$this->user->getProjectActivity(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetProjectActivityAllowed()
|
|
||||||
{
|
|
||||||
$activity = $this->user->getProjectActivity(2);
|
|
||||||
$this->assertNotEmpty($activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMyActivityStream()
|
|
||||||
{
|
|
||||||
$activity = $this->user->getMyActivityStream();
|
|
||||||
$this->assertNotEmpty($activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCloseTask()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->user->closeTask(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOpenTask()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->user->openTask(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveTaskPosition()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->user->moveTaskPosition(2, 1, 2, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateTaskWithWrongMember()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateTask()
|
|
||||||
{
|
|
||||||
$this->assertTrue($this->user->updateTask(array('id' => 1, 'title' => 'new title', 'reference' => 'test', 'owner_id' => 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetbyReference()
|
|
||||||
{
|
|
||||||
$task = $this->user->getTaskByReference(2, 'test');
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals('new title', $task['title']);
|
|
||||||
$this->assertEquals(2, $task['column_id']);
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMyDashboard()
|
|
||||||
{
|
{
|
||||||
$dashboard = $this->user->getMyDashboard();
|
$dashboard = $this->user->getMyDashboard();
|
||||||
$this->assertNotEmpty($dashboard);
|
$this->assertNotEmpty($dashboard);
|
||||||
|
|
@ -212,36 +65,9 @@ class MeTest extends Base
|
||||||
$this->assertNotEmpty($dashboard['tasks']);
|
$this->assertNotEmpty($dashboard['tasks']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetBoard()
|
public function assertGetMyActivityStream()
|
||||||
{
|
{
|
||||||
$this->assertNotEmpty($this->user->getBoard(2));
|
$activity = $this->user->getMyActivityStream();
|
||||||
}
|
$this->assertNotEmpty($activity);
|
||||||
|
|
||||||
public function testCreateOverdueTask()
|
|
||||||
{
|
|
||||||
$this->assertNotFalse($this->user->createTask(array(
|
|
||||||
'title' => 'overdue task',
|
|
||||||
'project_id' => 2,
|
|
||||||
'date_due' => date('Y-m-d', strtotime('-2days')),
|
|
||||||
'owner_id' => 2,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMyOverdueTasks()
|
|
||||||
{
|
|
||||||
$tasks = $this->user->getMyOverdueTasks();
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
|
||||||
$this->assertEquals('my project', $tasks[0]['project_name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetOverdueTasksByProject()
|
|
||||||
{
|
|
||||||
$tasks = $this->user->getOverdueTasksByProject(2);
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('overdue task', $tasks[0]['title']);
|
|
||||||
$this->assertEquals('my project', $tasks[0]['project_name']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class OverdueTaskTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test overdue tasks';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateOverdueTask();
|
||||||
|
$this->assertGetOverdueTasksByProject();
|
||||||
|
$this->assertGetOverdueTasks();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateOverdueTask()
|
||||||
|
{
|
||||||
|
$this->assertNotFalse($this->app->createTask(array(
|
||||||
|
'title' => 'overdue task',
|
||||||
|
'project_id' => $this->projectId,
|
||||||
|
'date_due' => date('Y-m-d', strtotime('-2days')),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetOverdueTasksByProject()
|
||||||
|
{
|
||||||
|
$tasks = $this->app->getOverdueTasksByProject($this->projectId);
|
||||||
|
$this->assertNotEmpty($tasks);
|
||||||
|
$this->assertCount(1, $tasks);
|
||||||
|
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||||
|
$this->assertEquals($this->projectName, $tasks[0]['project_name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetOverdueTasks()
|
||||||
|
{
|
||||||
|
$tasks = $this->app->getOverdueTasks();
|
||||||
|
$this->assertNotEmpty($tasks);
|
||||||
|
$this->assertCount(1, $tasks);
|
||||||
|
$this->assertEquals('overdue task', $tasks[0]['title']);
|
||||||
|
$this->assertEquals($this->projectName, $tasks[0]['project_name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,64 +1,89 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class ProjectPermissionTest extends Base
|
class ProjectPermissionTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testGetProjectUsers()
|
protected $projectName = 'Project with permission';
|
||||||
|
protected $username = 'user-project-permission';
|
||||||
|
protected $groupName1 = 'My group A for project permission';
|
||||||
|
protected $groupName2 = 'My group B for project permission';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertNotFalse($this->app->createProject('Test'));
|
$this->assertCreateTeamProject();
|
||||||
$this->assertNotFalse($this->app->createGroup('Test'));
|
$this->assertCreateGroups();
|
||||||
|
$this->assertCreateUser();
|
||||||
|
|
||||||
$projectId = $this->getProjectId();
|
$this->assertAddProjectUser();
|
||||||
$groupId = $this->getGroupId();
|
$this->assertGetProjectUsers();
|
||||||
|
$this->assertGetAssignableUsers();
|
||||||
|
$this->assertChangeProjectUserRole();
|
||||||
|
$this->assertRemoveProjectUser();
|
||||||
|
|
||||||
$this->assertTrue($this->app->addGroupMember($projectId, $groupId));
|
$this->assertAddProjectGroup();
|
||||||
$this->assertSame(array(), $this->app->getProjectUsers($projectId));
|
$this->assertGetProjectUsers();
|
||||||
|
$this->assertGetAssignableUsers();
|
||||||
|
$this->assertChangeProjectGroupRole();
|
||||||
|
$this->assertRemoveProjectGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProjectUser()
|
public function assertAddProjectUser()
|
||||||
{
|
{
|
||||||
$projectId = $this->getProjectId();
|
$this->assertTrue($this->app->addProjectUser($this->projectId, $this->userId));
|
||||||
$this->assertTrue($this->app->addProjectUser($projectId, 1));
|
|
||||||
|
|
||||||
$users = $this->app->getProjectUsers($projectId);
|
|
||||||
$this->assertCount(1, $users);
|
|
||||||
$this->assertEquals('admin', $users[1]);
|
|
||||||
|
|
||||||
$users = $this->app->getAssignableUsers($projectId);
|
|
||||||
$this->assertCount(1, $users);
|
|
||||||
$this->assertEquals('admin', $users[1]);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->changeProjectUserRole($projectId, 1, 'project-viewer'));
|
|
||||||
|
|
||||||
$users = $this->app->getAssignableUsers($projectId);
|
|
||||||
$this->assertCount(0, $users);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->removeProjectUser($projectId, 1));
|
|
||||||
$this->assertSame(array(), $this->app->getProjectUsers($projectId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProjectGroup()
|
public function assertGetProjectUsers()
|
||||||
{
|
{
|
||||||
$projectId = $this->getProjectId();
|
$members = $this->app->getProjectUsers($this->projectId);
|
||||||
$groupId = $this->getGroupId();
|
$this->assertCount(1, $members);
|
||||||
|
$this->assertArrayHasKey($this->userId, $members);
|
||||||
|
$this->assertEquals($this->username, $members[$this->userId]);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->app->addProjectGroup($projectId, $groupId));
|
public function assertGetAssignableUsers()
|
||||||
|
{
|
||||||
|
$members = $this->app->getAssignableUsers($this->projectId);
|
||||||
|
$this->assertCount(1, $members);
|
||||||
|
$this->assertArrayHasKey($this->userId, $members);
|
||||||
|
$this->assertEquals($this->username, $members[$this->userId]);
|
||||||
|
}
|
||||||
|
|
||||||
$users = $this->app->getProjectUsers($projectId);
|
public function assertChangeProjectUserRole()
|
||||||
$this->assertCount(1, $users);
|
{
|
||||||
$this->assertEquals('admin', $users[1]);
|
$this->assertTrue($this->app->changeProjectUserRole($this->projectId, $this->userId, 'project-viewer'));
|
||||||
|
|
||||||
$users = $this->app->getAssignableUsers($projectId);
|
$members = $this->app->getAssignableUsers($this->projectId);
|
||||||
$this->assertCount(1, $users);
|
$this->assertCount(0, $members);
|
||||||
$this->assertEquals('admin', $users[1]);
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->app->changeProjectGroupRole($projectId, $groupId, 'project-viewer'));
|
public function assertRemoveProjectUser()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeProjectUser($this->projectId, $this->userId));
|
||||||
|
|
||||||
$users = $this->app->getAssignableUsers($projectId);
|
$members = $this->app->getProjectUsers($this->projectId);
|
||||||
$this->assertCount(0, $users);
|
$this->assertCount(0, $members);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->app->removeProjectGroup($projectId, 1));
|
public function assertAddProjectGroup()
|
||||||
$this->assertSame(array(), $this->app->getProjectUsers($projectId));
|
{
|
||||||
|
$this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId));
|
||||||
|
$this->assertTrue($this->app->addProjectGroup($this->projectId, $this->groupId1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertChangeProjectGroupRole()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->changeProjectGroupRole($this->projectId, $this->groupId1, 'project-viewer'));
|
||||||
|
|
||||||
|
$members = $this->app->getAssignableUsers($this->projectId);
|
||||||
|
$this->assertCount(0, $members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveProjectGroup()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeProjectGroup($this->projectId, $this->groupId1));
|
||||||
|
|
||||||
|
$members = $this->app->getProjectUsers($this->projectId);
|
||||||
|
$this->assertCount(0, $members);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class ProjectTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My team project';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertGetProjectById();
|
||||||
|
$this->assertGetProjectByName();
|
||||||
|
$this->assertGetAllProjects();
|
||||||
|
$this->assertUpdateProject();
|
||||||
|
$this->assertGetProjectActivity();
|
||||||
|
$this->assertGetProjectsActivity();
|
||||||
|
$this->assertEnableDisableProject();
|
||||||
|
$this->assertEnableDisablePublicAccess();
|
||||||
|
$this->assertRemoveProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetProjectById()
|
||||||
|
{
|
||||||
|
$project = $this->app->getProjectById($this->projectId);
|
||||||
|
$this->assertNotNull($project);
|
||||||
|
$this->assertEquals($this->projectName, $project['name']);
|
||||||
|
$this->assertEquals('Description', $project['description']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetProjectByName()
|
||||||
|
{
|
||||||
|
$project = $this->app->getProjectByName($this->projectName);
|
||||||
|
$this->assertNotNull($project);
|
||||||
|
$this->assertEquals($this->projectId, $project['id']);
|
||||||
|
$this->assertEquals($this->projectName, $project['name']);
|
||||||
|
$this->assertEquals('Description', $project['description']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllProjects()
|
||||||
|
{
|
||||||
|
$projects = $this->app->getAllProjects();
|
||||||
|
$this->assertNotEmpty($projects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetProjectActivity()
|
||||||
|
{
|
||||||
|
$activities = $this->app->getProjectActivity($this->projectId);
|
||||||
|
$this->assertInternalType('array', $activities);
|
||||||
|
$this->assertCount(0, $activities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetProjectsActivity()
|
||||||
|
{
|
||||||
|
$activities = $this->app->getProjectActivities(array('project_ids' => array($this->projectId)));
|
||||||
|
$this->assertInternalType('array', $activities);
|
||||||
|
$this->assertCount(0, $activities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertUpdateProject()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => 'test', 'description' => 'test')));
|
||||||
|
|
||||||
|
$project = $this->app->getProjectById($this->projectId);
|
||||||
|
$this->assertNotNull($project);
|
||||||
|
$this->assertEquals('test', $project['name']);
|
||||||
|
$this->assertEquals('test', $project['description']);
|
||||||
|
|
||||||
|
$this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => $this->projectName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertEnableDisableProject()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->disableProject($this->projectId));
|
||||||
|
$this->assertTrue($this->app->enableProject($this->projectId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertEnableDisablePublicAccess()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->disableProjectPublicAccess($this->projectId));
|
||||||
|
$this->assertTrue($this->app->enableProjectPublicAccess($this->projectId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveProject()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeProject($this->projectId));
|
||||||
|
$this->assertNull($this->app->getProjectById($this->projectId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class SubtaskTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test subtasks';
|
||||||
|
private $subtaskId = 0;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateTask();
|
||||||
|
$this->assertCreateSubtask();
|
||||||
|
$this->assertGetSubtask();
|
||||||
|
$this->assertUpdateSubtask();
|
||||||
|
$this->assertGetAllSubtasks();
|
||||||
|
$this->assertRemoveSubtask();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateSubtask()
|
||||||
|
{
|
||||||
|
$this->subtaskId = $this->app->createSubtask(array(
|
||||||
|
'task_id' => $this->taskId,
|
||||||
|
'title' => 'subtask #1',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertNotFalse($this->subtaskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetSubtask()
|
||||||
|
{
|
||||||
|
$subtask = $this->app->getSubtask($this->subtaskId);
|
||||||
|
$this->assertEquals($this->taskId, $subtask['task_id']);
|
||||||
|
$this->assertEquals('subtask #1', $subtask['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertUpdateSubtask()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->execute('updateSubtask', array(
|
||||||
|
'id' => $this->subtaskId,
|
||||||
|
'task_id' => $this->taskId,
|
||||||
|
'title' => 'test',
|
||||||
|
)));
|
||||||
|
|
||||||
|
$subtask = $this->app->getSubtask($this->subtaskId);
|
||||||
|
$this->assertEquals('test', $subtask['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllSubtasks()
|
||||||
|
{
|
||||||
|
$subtasks = $this->app->getAllSubtasks($this->taskId);
|
||||||
|
$this->assertCount(1, $subtasks);
|
||||||
|
$this->assertEquals('test', $subtasks[0]['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveSubtask()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeSubtask($this->subtaskId));
|
||||||
|
|
||||||
|
$subtasks = $this->app->getAllSubtasks($this->taskId);
|
||||||
|
$this->assertCount(0, $subtasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,103 +1,93 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class SwimlaneTest extends Base
|
class SwimlaneTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testCreateProject()
|
protected $projectName = 'My project to test swimlanes';
|
||||||
|
private $swimlaneId = 0;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertEquals(1, $this->app->createProject('A project'));
|
$this->assertCreateTeamProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDefaultSwimlane()
|
public function assertGetDefaultSwimlane()
|
||||||
{
|
{
|
||||||
$swimlane = $this->app->getDefaultSwimlane(1);
|
$swimlane = $this->app->getDefaultSwimlane($this->projectId);
|
||||||
$this->assertNotEmpty($swimlane);
|
$this->assertNotEmpty($swimlane);
|
||||||
$this->assertEquals('Default swimlane', $swimlane['default_swimlane']);
|
$this->assertEquals('Default swimlane', $swimlane['default_swimlane']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddSwimlane()
|
public function assertAddSwimlane()
|
||||||
{
|
{
|
||||||
$swimlane_id = $this->app->addSwimlane(1, 'Swimlane 1');
|
$this->swimlaneId = $this->app->addSwimlane($this->projectId, 'Swimlane 1');
|
||||||
$this->assertNotFalse($swimlane_id);
|
$this->assertNotFalse($this->swimlaneId);
|
||||||
$this->assertInternalType('int', $swimlane_id);
|
$this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane 2'));
|
||||||
|
}
|
||||||
|
|
||||||
$swimlane = $this->app->getSwimlaneById($swimlane_id);
|
public function assertGetSwimlane()
|
||||||
$this->assertNotEmpty($swimlane);
|
{
|
||||||
|
$swimlane = $this->app->getSwimlane($this->swimlaneId);
|
||||||
$this->assertInternalType('array', $swimlane);
|
$this->assertInternalType('array', $swimlane);
|
||||||
$this->assertEquals('Swimlane 1', $swimlane['name']);
|
$this->assertEquals('Swimlane 1', $swimlane['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSwimlane()
|
public function assertUpdateSwimlane()
|
||||||
{
|
{
|
||||||
$swimlane = $this->app->getSwimlane(1);
|
$this->assertTrue($this->app->updateSwimlane($this->swimlaneId, 'Another swimlane'));
|
||||||
$this->assertInternalType('array', $swimlane);
|
|
||||||
$this->assertEquals('Swimlane 1', $swimlane['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateSwimlane()
|
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
|
||||||
{
|
|
||||||
$swimlane = $this->app->getSwimlaneByName(1, 'Swimlane 1');
|
|
||||||
$this->assertInternalType('array', $swimlane);
|
|
||||||
$this->assertEquals(1, $swimlane['id']);
|
|
||||||
$this->assertEquals('Swimlane 1', $swimlane['name']);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->updateSwimlane($swimlane['id'], 'Another swimlane'));
|
|
||||||
|
|
||||||
$swimlane = $this->app->getSwimlaneById($swimlane['id']);
|
|
||||||
$this->assertEquals('Another swimlane', $swimlane['name']);
|
$this->assertEquals('Another swimlane', $swimlane['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisableSwimlane()
|
public function assertDisableSwimlane()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->disableSwimlane(1, 1));
|
$this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId));
|
||||||
|
|
||||||
$swimlane = $this->app->getSwimlaneById(1);
|
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
|
||||||
$this->assertEquals(0, $swimlane['is_active']);
|
$this->assertEquals(0, $swimlane['is_active']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnableSwimlane()
|
public function assertEnableSwimlane()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->enableSwimlane(1, 1));
|
$this->assertTrue($this->app->enableSwimlane($this->projectId, $this->swimlaneId));
|
||||||
|
|
||||||
$swimlane = $this->app->getSwimlaneById(1);
|
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
|
||||||
$this->assertEquals(1, $swimlane['is_active']);
|
$this->assertEquals(1, $swimlane['is_active']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAllSwimlanes()
|
public function assertGetAllSwimlanes()
|
||||||
{
|
{
|
||||||
$this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane A'));
|
$swimlanes = $this->app->getAllSwimlanes($this->projectId);
|
||||||
|
|
||||||
$swimlanes = $this->app->getAllSwimlanes(1);
|
|
||||||
$this->assertCount(2, $swimlanes);
|
$this->assertCount(2, $swimlanes);
|
||||||
$this->assertEquals('Another swimlane', $swimlanes[0]['name']);
|
$this->assertEquals('Another swimlane', $swimlanes[0]['name']);
|
||||||
$this->assertEquals('Swimlane A', $swimlanes[1]['name']);
|
$this->assertEquals('Swimlane 2', $swimlanes[1]['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetActiveSwimlane()
|
public function assertGetActiveSwimlane()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->disableSwimlane(1, 1));
|
$this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId));
|
||||||
|
|
||||||
$swimlanes = $this->app->getActiveSwimlanes(1);
|
$swimlanes = $this->app->getActiveSwimlanes($this->projectId);
|
||||||
$this->assertCount(2, $swimlanes);
|
$this->assertCount(2, $swimlanes);
|
||||||
$this->assertEquals('Default swimlane', $swimlanes[0]['name']);
|
$this->assertEquals('Default swimlane', $swimlanes[0]['name']);
|
||||||
$this->assertEquals('Swimlane A', $swimlanes[1]['name']);
|
$this->assertEquals('Swimlane 2', $swimlanes[1]['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemoveSwimlane()
|
public function assertRemoveSwimlane()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->removeSwimlane(1, 2));
|
$this->assertTrue($this->app->removeSwimlane($this->projectId, $this->swimlaneId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangePosition()
|
public function assertChangePosition()
|
||||||
{
|
{
|
||||||
$this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane 1'));
|
$swimlaneId1 = $this->app->addSwimlane($this->projectId, 'Swimlane A');
|
||||||
$this->assertNotFalse($this->app->addSwimlane(1, 'Swimlane 2'));
|
$this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane B'));
|
||||||
|
|
||||||
$swimlanes = $this->app->getAllSwimlanes(1);
|
$swimlanes = $this->app->getAllSwimlanes($this->projectId);
|
||||||
$this->assertCount(3, $swimlanes);
|
$this->assertCount(3, $swimlanes);
|
||||||
|
|
||||||
$this->assertTrue($this->app->changeSwimlanePosition(1, 1, 3));
|
$this->assertTrue($this->app->changeSwimlanePosition($this->projectId, $swimlaneId1, 3));
|
||||||
$this->assertFalse($this->app->changeSwimlanePosition(1, 1, 6));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class TaskFileTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test task files';
|
||||||
|
protected $fileId;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
$this->assertCreateTask();
|
||||||
|
$this->assertCreateTaskFile();
|
||||||
|
$this->assertGetTaskFile();
|
||||||
|
$this->assertDownloadTaskFile();
|
||||||
|
$this->assertGetAllFiles();
|
||||||
|
$this->assertRemoveTaskFile();
|
||||||
|
$this->assertRemoveAllTaskFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateTaskFile()
|
||||||
|
{
|
||||||
|
$this->fileId = $this->app->createTaskFile(1, $this->taskId, 'My file', base64_encode('plain text file'));
|
||||||
|
$this->assertNotFalse($this->fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetTaskFile()
|
||||||
|
{
|
||||||
|
$file = $this->app->getTaskFile($this->fileId);
|
||||||
|
$this->assertNotEmpty($file);
|
||||||
|
$this->assertEquals('My file', $file['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertDownloadTaskFile()
|
||||||
|
{
|
||||||
|
$content = $this->app->downloadTaskFile($this->fileId);
|
||||||
|
$this->assertNotEmpty($content);
|
||||||
|
$this->assertEquals('plain text file', base64_decode($content));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllFiles()
|
||||||
|
{
|
||||||
|
$files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId));
|
||||||
|
$this->assertCount(1, $files);
|
||||||
|
$this->assertEquals('My file', $files[0]['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveTaskFile()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeTaskFile($this->fileId));
|
||||||
|
|
||||||
|
$files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId));
|
||||||
|
$this->assertEmpty($files);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveAllTaskFiles()
|
||||||
|
{
|
||||||
|
$this->assertCreateTaskFile();
|
||||||
|
$this->assertCreateTaskFile();
|
||||||
|
|
||||||
|
$this->assertTrue($this->app->removeAllTaskFiles($this->taskId));
|
||||||
|
|
||||||
|
$files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId));
|
||||||
|
$this->assertEmpty($files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
|
class TaskLinkTest extends BaseIntegrationTest
|
||||||
|
{
|
||||||
|
protected $projectName = 'My project to test task links';
|
||||||
|
protected $taskLinkId;
|
||||||
|
protected $taskId1;
|
||||||
|
protected $taskId2;
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
|
{
|
||||||
|
$this->assertCreateTeamProject();
|
||||||
|
|
||||||
|
$this->taskId1 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 1'));
|
||||||
|
$this->taskId2 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 2'));
|
||||||
|
|
||||||
|
$this->assertNotFalse($this->taskId1);
|
||||||
|
$this->assertNotFalse($this->taskId2);
|
||||||
|
|
||||||
|
$this->assertCreateTaskLink();
|
||||||
|
$this->assertGetTaskLink();
|
||||||
|
$this->assertGetAllTaskLinks();
|
||||||
|
$this->assertUpdateTaskLink();
|
||||||
|
$this->assertRemoveTaskLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCreateTaskLink()
|
||||||
|
{
|
||||||
|
$this->taskLinkId = $this->app->createTaskLink($this->taskId1, $this->taskId2, 1);
|
||||||
|
$this->assertNotFalse($this->taskLinkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetTaskLink()
|
||||||
|
{
|
||||||
|
$link = $this->app->getTaskLinkById($this->taskLinkId);
|
||||||
|
$this->assertNotNull($link);
|
||||||
|
$this->assertEquals($this->taskId1, $link['task_id']);
|
||||||
|
$this->assertEquals($this->taskId2, $link['opposite_task_id']);
|
||||||
|
$this->assertEquals(1, $link['link_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllTaskLinks()
|
||||||
|
{
|
||||||
|
$links = $this->app->getAllTaskLinks($this->taskId2);
|
||||||
|
$this->assertCount(1, $links);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertUpdateTaskLink()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->updateTaskLink($this->taskLinkId, $this->taskId1, $this->taskId2, 3));
|
||||||
|
|
||||||
|
$link = $this->app->getTaskLinkById($this->taskLinkId);
|
||||||
|
$this->assertNotNull($link);
|
||||||
|
$this->assertEquals($this->taskId1, $link['task_id']);
|
||||||
|
$this->assertEquals($this->taskId2, $link['opposite_task_id']);
|
||||||
|
$this->assertEquals(3, $link['link_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveTaskLink()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeTaskLink($this->taskLinkId));
|
||||||
|
|
||||||
|
$links = $this->app->getAllTaskLinks($this->taskId2);
|
||||||
|
$this->assertCount(0, $links);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,132 +1,55 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class TaskTest extends Base
|
class TaskTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testSearchTasks()
|
protected $projectName = 'My project to test tasks';
|
||||||
|
|
||||||
|
public function testAll()
|
||||||
{
|
{
|
||||||
$project_id1 = $this->app->createProject('My project');
|
$this->assertCreateTeamProject();
|
||||||
$project_id2 = $this->app->createProject('My project');
|
$this->assertCreateTask();
|
||||||
$this->assertNotFalse($project_id1);
|
$this->assertUpdateTask();
|
||||||
$this->assertNotFalse($project_id2);
|
$this->assertGetTaskById();
|
||||||
|
$this->assertGetTaskByReference();
|
||||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T1')));
|
$this->assertGetAllTasks();
|
||||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T2')));
|
$this->assertOpenCloseTask();
|
||||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id2, 'title' => 'T3')));
|
|
||||||
|
|
||||||
$tasks = $this->app->searchTasks($project_id1, 't2');
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('T2', $tasks[0]['title']);
|
|
||||||
|
|
||||||
$tasks = $this->app->searchTasks(array('project_id' => $project_id2, 'query' => 'assignee:nobody'));
|
|
||||||
$this->assertCount(1, $tasks);
|
|
||||||
$this->assertEquals('T3', $tasks[0]['title']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPriorityAttribute()
|
public function assertUpdateTask()
|
||||||
{
|
{
|
||||||
$project_id = $this->app->createProject('My project');
|
$this->assertTrue($this->app->updateTask(array('id' => $this->taskId, 'color_id' => 'red')));
|
||||||
$this->assertNotFalse($project_id);
|
|
||||||
|
|
||||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'priority' => 2));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals(2, $task['priority']);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'priority' => 3)));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals(3, $task['priority']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeAssigneeToAssignableUser()
|
public function assertGetTaskById()
|
||||||
{
|
{
|
||||||
$project_id = $this->app->createProject('My project');
|
$task = $this->app->getTask($this->taskId);
|
||||||
$this->assertNotFalse($project_id);
|
$this->assertNotNull($task);
|
||||||
|
$this->assertEquals('red', $task['color_id']);
|
||||||
$user_id = $this->app->createUser('user0', 'password');
|
$this->assertEquals($this->taskTitle, $task['title']);
|
||||||
$this->assertNotFalse($user_id);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member'));
|
|
||||||
|
|
||||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task'));
|
|
||||||
$this->assertNotFalse($task_id);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => $user_id)));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals($user_id, $task['owner_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeAssigneeToNotAssignableUser()
|
public function assertGetTaskByReference()
|
||||||
{
|
{
|
||||||
$project_id = $this->app->createProject('My project');
|
$taskId = $this->app->createTask(array('title' => 'task with reference', 'project_id' => $this->projectId, 'reference' => 'test'));
|
||||||
$this->assertNotFalse($project_id);
|
$this->assertNotFalse($taskId);
|
||||||
|
|
||||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task'));
|
$task = $this->app->getTaskByReference($this->projectId, 'test');
|
||||||
$this->assertNotFalse($task_id);
|
$this->assertNotNull($task);
|
||||||
|
$this->assertEquals($taskId, $task['id']);
|
||||||
$this->assertFalse($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 1)));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeAssigneeToNobody()
|
public function assertGetAllTasks()
|
||||||
{
|
{
|
||||||
$project_id = $this->app->createProject('My project');
|
$tasks = $this->app->getAllTasks($this->projectId);
|
||||||
$this->assertNotFalse($project_id);
|
$this->assertInternalType('array', $tasks);
|
||||||
|
$this->assertNotEmpty($tasks);
|
||||||
$user_id = $this->app->createUser('user1', 'password');
|
|
||||||
$this->assertNotFalse($user_id);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member'));
|
|
||||||
|
|
||||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'owner_id' => $user_id));
|
|
||||||
$this->assertNotFalse($task_id);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 0)));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMoveTaskToAnotherProject()
|
public function assertOpenCloseTask()
|
||||||
{
|
{
|
||||||
$project_id1 = $this->app->createProject('My project');
|
$this->assertTrue($this->app->closeTask($this->taskId));
|
||||||
$this->assertNotFalse($project_id1);
|
$this->assertTrue($this->app->openTask($this->taskId));
|
||||||
|
|
||||||
$project_id2 = $this->app->createProject('My project');
|
|
||||||
$this->assertNotFalse($project_id2);
|
|
||||||
|
|
||||||
$task_id = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task'));
|
|
||||||
$this->assertNotFalse($task_id);
|
|
||||||
|
|
||||||
$this->assertTrue($this->app->moveTaskToProject($task_id, $project_id2));
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id);
|
|
||||||
$this->assertEquals($project_id2, $task['project_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveCopyToAnotherProject()
|
|
||||||
{
|
|
||||||
$project_id1 = $this->app->createProject('My project');
|
|
||||||
$this->assertNotFalse($project_id1);
|
|
||||||
|
|
||||||
$project_id2 = $this->app->createProject('My project');
|
|
||||||
$this->assertNotFalse($project_id2);
|
|
||||||
|
|
||||||
$task_id1 = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task'));
|
|
||||||
$this->assertNotFalse($task_id1);
|
|
||||||
|
|
||||||
$task_id2 = $this->app->duplicateTaskToProject($task_id1, $project_id2);
|
|
||||||
$this->assertNotFalse($task_id2);
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id1);
|
|
||||||
$this->assertEquals($project_id1, $task['project_id']);
|
|
||||||
|
|
||||||
$task = $this->app->getTask($task_id2);
|
|
||||||
$this->assertEquals($project_id2, $task['project_id']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,63 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||||
|
|
||||||
class UserTest extends Base
|
class UserTest extends BaseIntegrationTest
|
||||||
{
|
{
|
||||||
public function testDisableUser()
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->assertEquals(2, $this->app->createUser(array('username' => 'someone', 'password' => 'test123')));
|
$this->assertCreateUser();
|
||||||
$this->assertTrue($this->app->isActiveUser(2));
|
$this->assertGetUserById();
|
||||||
|
$this->assertGetUserByName();
|
||||||
|
$this->assertGetAllUsers();
|
||||||
|
$this->assertEnableDisableUser();
|
||||||
|
$this->assertUpdateUser();
|
||||||
|
$this->assertRemoveUser();
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->app->disableUser(2));
|
public function assertGetUserById()
|
||||||
$this->assertFalse($this->app->isActiveUser(2));
|
{
|
||||||
|
$user = $this->app->getUser($this->userId);
|
||||||
|
$this->assertNotNull($user);
|
||||||
|
$this->assertEquals($this->username, $user['username']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->app->enableUser(2));
|
public function assertGetUserByName()
|
||||||
$this->assertTrue($this->app->isActiveUser(2));
|
{
|
||||||
|
$user = $this->app->getUserByName($this->username);
|
||||||
|
$this->assertNotNull($user);
|
||||||
|
$this->assertEquals($this->username, $user['username']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertGetAllUsers()
|
||||||
|
{
|
||||||
|
$users = $this->app->getAllUsers();
|
||||||
|
$this->assertInternalType('array', $users);
|
||||||
|
$this->assertNotEmpty($users);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertEnableDisableUser()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->disableUser($this->userId));
|
||||||
|
$this->assertFalse($this->app->isActiveUser($this->userId));
|
||||||
|
$this->assertTrue($this->app->enableUser($this->userId));
|
||||||
|
$this->assertTrue($this->app->isActiveUser($this->userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertUpdateUser()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->updateUser(array(
|
||||||
|
'id' => $this->userId,
|
||||||
|
'name' => 'My user',
|
||||||
|
)));
|
||||||
|
|
||||||
|
$user = $this->app->getUser($this->userId);
|
||||||
|
$this->assertNotNull($user);
|
||||||
|
$this->assertEquals('My user', $user['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRemoveUser()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->removeUser($this->userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue