2016-01-24 17:50:51 +01:00
|
|
|
Automated tests
|
|
|
|
===============
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
[PHPUnit](https://phpunit.de/) is used to run automated tests on Kanboard.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
|
|
|
You can run tests across different databases (Sqlite, Mysql and Postgresql) to be sure that the result is the same everywhere.
|
|
|
|
|
|
|
|
Requirements
|
|
|
|
------------
|
|
|
|
|
|
|
|
- Linux/Unix machine
|
2016-01-24 17:50:51 +01:00
|
|
|
- PHP cli
|
2015-09-13 12:36:05 +02:00
|
|
|
- PHPUnit installed
|
|
|
|
- Mysql and Postgresql (optional)
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
Unit Tests
|
|
|
|
----------
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
### Test with Sqlite
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2015-12-29 01:24:09 +01:00
|
|
|
Sqlite tests use a in-memory database, nothing is written on the file system.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
The PHPUnit config file is `tests/units.sqlite.xml`.
|
2015-09-13 12:36:05 +02:00
|
|
|
From your Kanboard directory, run the command `phpunit -c tests/units.sqlite.xml`.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
phpunit -c tests/units.sqlite.xml
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
PHPUnit 5.0.0 by Sebastian Bergmann and contributors.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
............................................................... 63 / 649 ( 9%)
|
|
|
|
............................................................... 126 / 649 ( 19%)
|
|
|
|
............................................................... 189 / 649 ( 29%)
|
|
|
|
............................................................... 252 / 649 ( 38%)
|
|
|
|
............................................................... 315 / 649 ( 48%)
|
|
|
|
............................................................... 378 / 649 ( 58%)
|
|
|
|
............................................................... 441 / 649 ( 67%)
|
|
|
|
............................................................... 504 / 649 ( 77%)
|
|
|
|
............................................................... 567 / 649 ( 87%)
|
|
|
|
............................................................... 630 / 649 ( 97%)
|
|
|
|
................... 649 / 649 (100%)
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
Time: 1.22 minutes, Memory: 151.25Mb
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
OK (649 tests, 43595 assertions)
|
2015-09-13 12:36:05 +02:00
|
|
|
```
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
### Test with Mysql
|
2015-09-13 12:36:05 +02:00
|
|
|
|
|
|
|
You must have Mysql or MariaDb installed on localhost.
|
|
|
|
|
|
|
|
By default, those credentials are used:
|
|
|
|
|
|
|
|
- Hostname: **localhost**
|
|
|
|
- Username: **root**
|
|
|
|
- Password: none
|
|
|
|
- Database: **kanboard_unit_test**
|
|
|
|
|
|
|
|
For each execution the database is dropped and created again.
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
The PHPUnit config file is `tests/units.mysql.xml`.
|
2015-09-13 12:36:05 +02:00
|
|
|
From your Kanboard directory, run the command `phpunit -c tests/units.mysql.xml`.
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
### Test with Postgresql
|
2015-09-13 12:36:05 +02:00
|
|
|
|
|
|
|
You must have Postgresql installed on localhost.
|
|
|
|
|
|
|
|
By default, those credentials are used:
|
|
|
|
|
|
|
|
- Hostname: **localhost**
|
|
|
|
- Username: **postgres**
|
|
|
|
- Password: none
|
|
|
|
- Database: **kanboard_unit_test**
|
|
|
|
|
|
|
|
Be sure to allow the user `postgres` to create and drop databases.
|
2016-01-24 17:50:51 +01:00
|
|
|
The database is recreated for each execution.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
The PHPUnit config file is `tests/units.postgres.xml`.
|
2015-09-13 12:36:05 +02:00
|
|
|
From your Kanboard directory, run the command `phpunit -c tests/units.postgres.xml`.
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
Integration Tests
|
|
|
|
-----------------
|
2015-09-13 12:36:05 +02:00
|
|
|
|
|
|
|
Actually only the API calls are tested.
|
|
|
|
|
|
|
|
Real HTTP calls are made with those tests.
|
2016-01-24 17:50:51 +01:00
|
|
|
So a local instance of Kanboard is necessary and must listen on `http://localhost:8000/`.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
All data will be removed/altered by the test suite.
|
2015-09-13 12:36:05 +02:00
|
|
|
Moreover the script will reset and set a new API key.
|
|
|
|
|
|
|
|
1. Start a local instance of Kanboard `php -S 127.0.0.1:8000`
|
|
|
|
2. Run the test suite from another terminal
|
|
|
|
|
|
|
|
The same method as above is used to run tests across different databases:
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
- Sqlite: `phpunit -c tests/integration.sqlite.xml`
|
|
|
|
- Mysql: `phpunit -c tests/integration.mysql.xml`
|
|
|
|
- Postgresql: `phpunit -c tests/integration.postgres.xml`
|
2015-09-13 12:36:05 +02:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```bash
|
2016-01-24 17:50:51 +01:00
|
|
|
phpunit -c tests/integration.sqlite.xml
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
PHPUnit 5.0.0 by Sebastian Bergmann and contributors.
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
............................................................... 63 / 135 ( 46%)
|
|
|
|
............................................................... 126 / 135 ( 93%)
|
|
|
|
......... 135 / 135 (100%)
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
Time: 1.18 minutes, Memory: 14.75Mb
|
2015-09-13 12:36:05 +02:00
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
OK (135 tests, 526 assertions)
|
2015-09-13 12:36:05 +02:00
|
|
|
```
|
|
|
|
|
2016-01-24 17:50:51 +01:00
|
|
|
Continuous Integration with Travis-CI
|
2015-09-13 12:36:05 +02:00
|
|
|
-------------------------------------
|
|
|
|
|
|
|
|
After each commit pushed on the main repository, unit tests are executed across 5 different versions of PHP:
|
|
|
|
|
|
|
|
- PHP 7.0
|
|
|
|
- PHP 5.6
|
|
|
|
- PHP 5.5
|
|
|
|
- PHP 5.4
|
|
|
|
- PHP 5.3
|
|
|
|
|
|
|
|
Each version of PHP is tested against the 3 supported database: Sqlite, Mysql and Postgresql.
|
|
|
|
|
|
|
|
The Travis config file `.travis.yml` is located on the root directory of Kanboard.
|