Skip to content

Firefly III: a personal finances manager

Fix test script.

James Cole7ec9c090cc28
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
-
-
-# backup current config:
-mv .env .env.current
+DATABASE=./storage/database/database.sqlite
+DATABASECOPY=./storage/database/databasecopy.sqlite
+ORIGINALENV=./.env
+BACKUPENV=./.env.current
+TESTINGENV=./.env.testing
+
+# 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