diff --git a/.travis.yml b/.travis.yml index 55481d4251..a8f360bfff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/test.sh b/test.sh index ba4bde7d36..6190e186af 100755 --- a/test.sh +++ b/test.sh @@ -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