Testing


Unit Tests

TRAX LRS comes with a set of unit tests which can be run to check that your LRS is up and running, and that there is no regression after an update.

Before running the tests:

  1. Create a specific database for your tests.
  2. Create the .env.testing file (a copy of .env with the right DB settings).

{danger} Be sure to deactivate your config cache before running the tests: php artisan config:clear. Otherwise your current database will be deleted and used for the unit tests!

Then you can run all the tests:

vendor/bin/phpunit

You can run one of the 3 sets of tests:

vendor/bin/phpunit --testsuite auth
vendor/bin/phpunit --testsuite repo
vendor/bin/phpunit --testsuite xapi-store

You can run a given test file. For example:

vendor/bin/phpunit services/trax/test/auth/AuthenticationTest.php

You can run a given function inside a test file. For example:

vendor/bin/phpunit services/trax/test/auth/AuthenticationTest.php --filter testClientNoAuth

Note: unit tests do not support the use of queues, so don't enable queues in your testing config.

ADL Test Suite

ADL provides an LRS Conformance Test Suite to check that an LRS is xAPI conformant. TRAX LRS passed this test and we use it on a regular basis to check that there is no regression. Please, refer to the ADL documentation if you want to run this test.

Note: the ADL Test Suite fails when queues are enabled. Check the queues documentation to understand why.