All code submitted to the repository should have corresponding tests that pass.
The test suite assumes there is a
thinktank_tests database which the default ThinkTank db user can access. Each test should set up the appropriate test data in the
setUp() method and drop those tables in the
To run a particular test, like the UserDAO test, in the thinktank source code root folder, use this command:
$ php tests/userdao_test.php
To run all the tests, use:
$ php tests/all_tests.php
The webapp tests contained in
tests/frontend_test.php assumes you have a local installation of ThinkTank and that it is using the
thinktank_tests database. Make sure you update your
config.inc.php to point to the
thinktank_tests database before running the webapp tests.
Best practices for writing tests are still getting developed. In the meantime, use some existing tests as examples.
userdao_test.php as an example of a set of DAO tests.
Web Page Tests
Add tests for particular pages inside the webapp to
Crawler Consumption Tests
To test consumption of data from web services, mock up the appropriate classes and store test data to local files.
For example, the
classes/mock.TwitterOAuth.php class reads data from the files in the
Once your tests work, add them to the
all_tests.php file to run along with the existing tests.