#!/bin/bash # # USAGE: # runAllTests.sh [options] # -b Include data build tests in application. # -C Include class tests in lib/pkp. # -P Include plugin tests in lib/pkp. # -c Include class tests in application. # -p Include plugin tests in application. # -f Include functional tests in application. # -d Display debug output from phpunit. # If no options are specified, then all tests will be executed. # set -e # Fail on first error # Before executing tests for the first time please execute the # following commands from the main ojs directory to install # the default test environment. # # NB: This will replace your database and files directory, so # either use a separate application instance for testing or back-up # your original database and files before you execute tests! # # 1) Set up test data for functional tests: # # > rm -r files # > tar xzf tests/functional/files.tar.gz # > sudo chown -R testuser:www-data files cache # exchange www-data for your web server's group # # and testuser for the user that executes tests. # > chmod -R ug+w files cache # > rm cache/*.php # > mysql -u ... -p... ... java -jar selenium-server.jar -browserSessionReuse # Identify the tests directory. TESTS_DIR=`readlink -f "lib/pkp/tests"` # Shortcuts to the test environments. TEST_CONF1="--configuration $TESTS_DIR/phpunit-env1.xml" TEST_CONF2="--configuration $TESTS_DIR/phpunit-env2.xml" ### Command Line Options ### # Run all types of tests by default, unless one or more is specified DO_ALL=1 # Various types of tests DO_APP_DATA=0 DO_PKP_CLASSES=0 DO_PKP_PLUGINS=0 DO_APP_CLASSES=0 DO_APP_PLUGINS=0 DO_APP_FUNCTIONAL=0 DEBUG="" # Parse arguments while getopts "bCPcpfd" opt; do case "$opt" in b) DO_ALL=0 DO_APP_DATA=1 ;; C) DO_ALL=0 DO_PKP_CLASSES=1 ;; P) DO_ALL=0 DO_PKP_PLUGINS=1 ;; c) DO_ALL=0 DO_APP_CLASSES=1 ;; p) DO_ALL=0 DO_APP_PLUGINS=1 ;; f) DO_ALL=0 DO_APP_FUNCTIONAL=1 ;; d) DEBUG="--debug" ;; esac done if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_APP_DATA" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF1 --debug -v --stop-on-failure --stop-on-skipped tests/data fi if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_PKP_CLASSES" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF1 lib/pkp/tests/classes fi if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_PKP_PLUGINS" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF2 lib/pkp/tests/plugins fi if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_APP_CLASSES" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF1 tests/classes fi if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_APP_PLUGINS" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF2 tests/plugins fi if [ \( "$DO_ALL" -eq 1 \) -o \( "$DO_APP_FUNCTIONAL" -eq 1 \) ]; then phpunit $DEBUG $TEST_CONF1 tests/functional fi