Fix travis script.

This commit is contained in:
James Cole 2016-11-19 16:28:04 +01:00
parent 01e3f91ece
commit 5a2ef36f2a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 25 additions and 3 deletions

View File

@ -11,7 +11,7 @@ install:
- php artisan clear-compiled
- php artisan optimize
- php artisan env
- ./test.sh --notest --reset
- ./test.sh -r
- php artisan env
script:

26
test.sh
View File

@ -6,6 +6,20 @@ ORIGINALENV=./.env
BACKUPENV=./.env.current
TESTINGENV=./.env.testing
# do something with flags:
rflag=''
tflag=''
while getopts 'rt' flag; do
case "${flag}" in
r) rflag='true' ;;
t) tflag='true' ;;
*) error "Unexpected option ${flag}" ;;
esac
done
# backup current config (if it exists):
if [ -f $ORIGINALENV ]; then
mv $ORIGINALENV $BACKUPENV
@ -17,7 +31,8 @@ cp $TESTINGENV $ORIGINALENV
# clear cache:
php artisan cache:clear
if [[ "$@" == "--reset" ]]
# reset database (optional)
if [[ $rflag == "true" ]]
then
echo "Must reset database"
@ -35,14 +50,21 @@ then
cp $DATABASE $DATABASECOPY
fi
# do not reset database (optional)
if [[ $rflag == "" ]]
then
echo "Will not reset database"
fi
# take database from copy:
cp $DATABASECOPY $DATABASE
# run PHPUnit
if [[ "$@" == "--notest" ]]
if [[ $tflag == "" ]]
then
echo "Must not run PHPUnit"
else
echo "Must run PHPUnit"
phpunit
fi