mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Updated test script [skip ci]
This commit is contained in:
58
pu.sh
58
pu.sh
@@ -1,5 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
searchFile=""
|
||||
deleteDatabases=false
|
||||
|
||||
while getopts ":nhf:" opt; do
|
||||
case $opt in
|
||||
n)
|
||||
# echo "-n was triggered: new database!" >&2
|
||||
deleteDatabases=true
|
||||
;;
|
||||
f)
|
||||
#echo "-f was triggered: file! $OPTARG" >&2
|
||||
searchFile=$OPTARG
|
||||
;;
|
||||
h)
|
||||
echo "n: new database" >&2
|
||||
echo "f: which file to run" >&2
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# set testing environment
|
||||
cp .env.testing .env
|
||||
|
||||
@@ -10,20 +38,32 @@ cp phpunit.default.xml phpunit.xml
|
||||
touch storage/upload/at-1.data
|
||||
touch storage/upload/at-2.data
|
||||
|
||||
# delete databses:
|
||||
if [ "$deleteDatabases" = true ] ; then
|
||||
echo "Will delete and recreate the databases."
|
||||
|
||||
# delete test databases:
|
||||
# delete test database:
|
||||
if [ -f storage/database/testing.db ]
|
||||
then
|
||||
echo "Deleted testing.db"
|
||||
rm storage/database/testing.db
|
||||
fi
|
||||
|
||||
# delete test database copy:
|
||||
if [ -f storage/database/testing-copy.db ]
|
||||
then
|
||||
echo "Delete testing-copy.db"
|
||||
rm storage/database/testing-copy.db
|
||||
fi
|
||||
fi
|
||||
|
||||
# do not delete database:
|
||||
if [ "$deleteDatabases" = false ] ; then
|
||||
echo "Will not delete databases."
|
||||
fi
|
||||
|
||||
# test!
|
||||
if [ -z "$1" ]
|
||||
if [ "$searchFile" == "" ]
|
||||
then
|
||||
echo "Running all tests..."
|
||||
phpunit
|
||||
@@ -33,32 +73,30 @@ fi
|
||||
# test selective..
|
||||
dirs=("acceptance/Controllers" "acceptance/Controllers/Auth" "acceptance/Controllers/Chart" "unit")
|
||||
#
|
||||
if [ ! -z "$1" ]
|
||||
if [ "$searchFile" != "" ]
|
||||
then
|
||||
echo "Will run test for '$searchFile'"
|
||||
for i in "${dirs[@]}"
|
||||
do
|
||||
firstFile="./tests/$i/$1.php"
|
||||
secondFile="./tests/$i/$1Test.php"
|
||||
firstFile="./tests/$i/$searchFile.php"
|
||||
secondFile="./tests/$i/"$searchFile"Test.php"
|
||||
if [ -f "$firstFile" ]
|
||||
then
|
||||
# run it!
|
||||
echo "Now running $firstFile"
|
||||
echo "Found file '$firstFile'"
|
||||
phpunit --verbose $firstFile
|
||||
result=$?
|
||||
fi
|
||||
if [ -f "$secondFile" ]
|
||||
then
|
||||
# run it!
|
||||
echo "Now running $secondFile"
|
||||
echo "Found file '$secondFile'"
|
||||
phpunit --verbose $secondFile
|
||||
result=$?
|
||||
fi
|
||||
|
||||
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# restore .env file
|
||||
cp .env.local .env
|
||||
|
||||
|
Reference in New Issue
Block a user