Skip to content
Andy Theuninck edited this page Mar 27, 2015 · 7 revisions

CORE uses PHPUnit for testing. Installation instructions for PHPUnit can be found here. Alternately, CORE includes PHUnit as a composer dependency. Running "composer install" will install phpunit in the vendor/bin directory.

Tests are located in the pos/is4c-nf/unit-tests/ and fannie/unit-tests/ directory. Both directories include a bootstrap.php file that should be used with phpunit's --bootstrap option. The internal functionality is different for the different sets of tests, but each is responsible for setting up class autoloading and configuration variables.

Examples of running tests:

phpunit --bootstrap pos/is4c-nf/unit-tests/bootstrap.php pos/is4c-nf/unit-tests/SearchTest.php
phpunit --bootstrap fannie/unit-tets/bootstrap.php fannie/unit-tests/ItemsTest.php

Notable Tests

Both POS and Fannie include tests named InstallTest.php. These tests will create database structure and load sample data into these structures. Running this test first is often desirable because once it succeeds subsequent tests can issue test queries against the sample data. Fannie's InstallTest.php always uses databases named "unit_test_op" and "unit_test_trans". POS' InstallTest.php uses the currently configured database (patches welcome!). This means sample data will overwrite whatever's currently in those tables. Generally this is not a big deal since the lane database is just a copy of the authoritative back end database, but fair warning.

Both POS and Fannie include tests named PluginsTest.php. Because of the way plugin detection works in both components, .php files in the respective plugin directories may be included at any time. These tests try to verify nothing catastrophic happens when any plugin file is included. Fannie's version is currently more comprehensive. These tests are often useful in debugging weird behavior or random crashes.

Clone this wiki locally