2017-01-29 21:31:44 +08:00
|
|
|
Running PHP unit tests
|
|
|
|
======================
|
2012-08-26 06:49:11 +08:00
|
|
|
|
|
|
|
In order to run these tests, you will need to install the following packages
|
|
|
|
and its dependencies:
|
|
|
|
* phpunit
|
2016-11-13 18:01:51 +08:00
|
|
|
* php-gd
|
2016-12-25 17:58:35 +08:00
|
|
|
* php-sqlite3
|
2017-02-26 18:21:52 +08:00
|
|
|
* php-curl (optional, for codeclimate test reporter)
|
|
|
|
* php-xdebug (optional, for code coverage reports)
|
2012-08-26 06:49:11 +08:00
|
|
|
|
|
|
|
Example for Debian and Ubuntu:
|
2017-01-29 21:31:44 +08:00
|
|
|
```console
|
2017-02-26 18:21:52 +08:00
|
|
|
$ sudo apt install phpunit php-gd php-sqlite php-curl php-xdebug
|
2016-09-15 05:55:55 +08:00
|
|
|
```
|
2012-08-26 06:49:11 +08:00
|
|
|
|
|
|
|
To run the tests, just change into this directory and run phpunit:
|
2017-01-29 21:31:44 +08:00
|
|
|
```console
|
2016-09-15 05:55:55 +08:00
|
|
|
$ cd PrivateBin/tst
|
|
|
|
$ phpunit
|
|
|
|
```
|
2017-01-29 21:31:44 +08:00
|
|
|
|
|
|
|
Running JavaScript unit tests
|
|
|
|
=============================
|
|
|
|
|
|
|
|
In order to run these tests, you will need to install the following packages
|
|
|
|
and its dependencies:
|
|
|
|
* npm
|
|
|
|
|
|
|
|
Then you can use the node package manager to install the latest stable release
|
|
|
|
of mocha and istanbul (for code coverage reports) globally and jsVerify, jsdom
|
|
|
|
and jsdom-global locally:
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ npm install -g mocha istanbul
|
|
|
|
$ cd PrivateBin/js
|
|
|
|
$ npm install jsverify jsdom jsdom-global
|
|
|
|
```
|
|
|
|
|
|
|
|
Example for Debian and Ubuntu, including steps to allow current user to install
|
|
|
|
node modules globally:
|
|
|
|
```console
|
|
|
|
$ sudo apt install npm
|
|
|
|
$ sudo mkdir /usr/local/lib/node_modules
|
|
|
|
$ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
|
|
|
|
$ ln -s /usr/bin/nodejs /usr/local/bin/node
|
|
|
|
$ npm install -g mocha istanbul
|
|
|
|
$ cd PrivateBin/js
|
|
|
|
$ npm install jsverify jsdom jsdom-global
|
|
|
|
```
|
|
|
|
|
|
|
|
To run the tests, just change into the `js` directory and run istanbul:
|
|
|
|
```console
|
|
|
|
$ cd PrivateBin/js
|
|
|
|
$ istanbul cover _mocha
|
|
|
|
```
|
|
|
|
|