From 7ec9c090cc28849aaf1f88b0578bf01ed769bd6e Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 19 Nov 2016 16:13:57 +0100 Subject: [PATCH] Fix test script. --- .travis.yml | 2 +- test.sh | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d768b2bcd..efb24c6544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: - php artisan env - mv -v .env.testing .env - php artisan env - - ./test.sh --notest + - ./test.sh --notest --reset script: - phpunit \ No newline at end of file diff --git a/test.sh b/test.sh index 0ece8440dc..ba4bde7d36 100755 --- a/test.sh +++ b/test.sh @@ -1,19 +1,24 @@ #!/bin/bash -DATABASE=storage/database/database.sqlite -DATABASECOPY=storage/database/databasecopy.sqlite +DATABASE=./storage/database/database.sqlite +DATABASECOPY=./storage/database/databasecopy.sqlite +ORIGINALENV=./.env +BACKUPENV=./.env.current +TESTINGENV=./.env.testing - -# backup current config: -mv .env .env.current +# backup current config (if it exists): +if [ -f $ORIGINALENV ]; then + mv $ORIGINALENV $BACKUPENV +fi # enable testing config -cp .env.testing .env +cp $TESTINGENV $ORIGINALENV # clear cache: php artisan cache:clear -if [ "$1" == "--reset" ]; then +if [[ "$@" == "--reset" ]] +then echo "Must reset database" # touch files to make sure they exist. @@ -34,11 +39,14 @@ fi cp $DATABASECOPY $DATABASE # run PHPUnit -if [ "$1" == "--notest" ]; then +if [[ "$@" == "--notest" ]] +then echo "Must not run PHPUnit" else phpunit fi # restore current config: -mv .env.current .env \ No newline at end of file +if [ -f $BACKUPENV ]; then + mv $BACKUPENV $ORIGINALENV +fi \ No newline at end of file