Large code bases are prone to unintentional issues popping up as the code grows and transitions in to more mature states. Small changes in the way the way one piece of how the code works can have a cascading effect on the code you are writing, causing a lot of wasted time spent tracking down the cause of the issue. Perhaps the best way of proactively dealing with this is writing unit tests that test pieces of code individually, and integration tests that test code against everything else that is happening in the codebase. If an issue does arise, it is much easier to then track down where the issues are and fix them quickly, and develop better code.
Omeka's testing suite relies on PHPUnit a testing framework for PHP. You can run the unit tests in three configurations, test the core and plugins, just the core, and just the plugins. To run the tests, go to the application/tests directory and run phpunit with the following commands:
cd /path/to/omeka/application/tests phpunit # runs all tests phpunit AllTests # runs all tests phpunit CoreTests # runs tests on the Omeka core phpunit PluginTests # runs tests in plugins
Install PHPUnit
Omeka's test suite currently requires PHPUnit 3.5 or higher.
The preferred way to install PHPUnit is through PEAR. Pretty much any recent PHP version already includes PEAR by default
Before you install PHPUnit, you first have to let PEAR know where to get PHPUnit and its dependencies. Run the following three commands in the shell (this only needs to be done once):
pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com
Now, you can actually install PHPUnit:
pear install phpunit/PHPUnit
To make sure the installation was successful, you can run:
phpunit --version
Which should print something like the following if PHPUnit has been installed:
PHPUnit 3.5.10 by Sebastian Bergmann
Test configuration
Configuration for Omeka tests is in application/tests/config.ini
.