source: trunk/tests/run_tests.sh @ 622

Last change on this file since 622 was 622, checked in by anonymous, 6 years ago

Add Email() sandbox mode. Add Email->send() test. Fix minor bugs.

File size: 1.2 KB
Line 
1#!/bin/bash
2
3# This script sets-up the test environment and runs all tests.
4# You'll want to define your local mysql credentials for a test
5# database as environment variables, e.g., in ~/.bash_profile:
6#  export DB_NAME="test"
7#  export DB_USER="test"
8#  export DB_PASS="..."
9
10function err {
11    MSG="$1";
12    IFS='';
13    echo -e $MSG 1>&2
14    exit 1;
15}
16
17# Be in the directory with all the tests.
18cd `dirname $0`;
19
20# Get required ENV variables.
21if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then
22    echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time.";
23fi
24for E in DB_SERVER DB_NAME DB_USER DB_PASS; do
25    while [[ -z ${!E} ]]; do
26        read -p "$E: " $E;
27    done
28    export $E;
29done
30
31# Create database.
32mysql -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`" || err "Failed to create database '${DB_NAME}";
33
34# Go!
35echo "Running the tests!";
36echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors.";
37
38# Config options go in phpunit.xml
39# phpunit --tap | grep -v '^ok '
40../vendor/phpunit/phpunit/composer/bin/phpunit --stderr || err "\nSomething went wrong (code $?). If there is no output above, check the php_error_log";
41
Note: See TracBrowser for help on using the repository browser.