Fix test script.

This commit is contained in:
James Cole 2016-11-19 16:13:57 +01:00
parent b057d69f8e
commit 7ec9c090cc
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 18 additions and 10 deletions

View File

@ -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

26
test.sh
View File

@ -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
if [ -f $BACKUPENV ]; then
mv $BACKUPENV $ORIGINALENV
fi