Known has a number of PHP unit tests that can be run in order to check that things are working correctly, and to protect against any code regression.
Running from Github
Unit tests will automatically be run when you submit a pull request on GitHub. You should rectify any errors which are reported, as pull requests with errors will not be merged.
Running unit tests on your local machine
First, ensure PHPUnit is installed. (Installation varies by system and is beyond the scope of this documentation.)
To run all the tests, from the Known root directory simply run
Some tests require a connection to your local Known instance, so if this is anything other than http://localhost, you need to set the
KNOWN_DOMAIN environment variable.
Before running the unit test, set this by running
Code style testing
Known includes a PHP Codesniffer ruleset.
Running style tests on your local machine
First, ensure PHP Code Sniffer is installed. (Installation varies by system and is beyond the scope of this documentation.)
A special set of Known code style rules is included with Known. To test against these rules, run the following from the Known root directory:
phpcs --standard=phpcs/known.xml --extensions=php .
PHP Code Sniffer works with individual folders, also. For example, to test the core
Idno engine folder, you can run:
phpcs --standard=phpcs/known.xml --extensions=php Idno
The codebase is in the process of being brought in line with these rules, and will be integrated with our continuous integration testing once this has been completed.
Contents of the
external folder are exempt from these rules and will not be tested.