Fix test script.

This commit is contained in:
James Cole
2016-11-19 16:13:57 +01:00
parent b057d69f8e
commit 7ec9c090cc
2 changed files with 18 additions and 10 deletions

View File

@@ -14,7 +14,7 @@ install:
- php artisan env - php artisan env
- mv -v .env.testing .env - mv -v .env.testing .env
- php artisan env - php artisan env
- ./test.sh --notest - ./test.sh --notest --reset
script: script:
- phpunit - phpunit

26
test.sh
View File

@@ -1,19 +1,24 @@
#!/bin/bash #!/bin/bash
DATABASE=storage/database/database.sqlite DATABASE=./storage/database/database.sqlite
DATABASECOPY=storage/database/databasecopy.sqlite DATABASECOPY=./storage/database/databasecopy.sqlite
ORIGINALENV=./.env
BACKUPENV=./.env.current
TESTINGENV=./.env.testing
# backup current config (if it exists):
# backup current config: if [ -f $ORIGINALENV ]; then
mv .env .env.current mv $ORIGINALENV $BACKUPENV
fi
# enable testing config # enable testing config
cp .env.testing .env cp $TESTINGENV $ORIGINALENV
# clear cache: # clear cache:
php artisan cache:clear php artisan cache:clear
if [ "$1" == "--reset" ]; then if [[ "$@" == "--reset" ]]
then
echo "Must reset database" echo "Must reset database"
# touch files to make sure they exist. # touch files to make sure they exist.
@@ -34,11 +39,14 @@ fi
cp $DATABASECOPY $DATABASE cp $DATABASECOPY $DATABASE
# run PHPUnit # run PHPUnit
if [ "$1" == "--notest" ]; then if [[ "$@" == "--notest" ]]
then
echo "Must not run PHPUnit" echo "Must not run PHPUnit"
else else
phpunit phpunit
fi fi
# restore current config: # restore current config:
mv .env.current .env if [ -f $BACKUPENV ]; then
mv $BACKUPENV $ORIGINALENV
fi