-
-
Save zuzuleinen/b5d7d8980840266f04be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function printHelp { | |
echo "Load fixtures and run tests" | |
echo "Usage: runTests.sh [options] [directory]" | |
echo "" | |
echo "Options:" | |
echo " -r|--reset resets the sqlite test database before testing" | |
echo " -h|--help print this help" | |
echo "" | |
echo "Directory:" | |
echo " Optionally you can supply a directory. In that case, all tests inside that" | |
echo " directory and its subdirectories will be run INSTEAD of the ones specified" | |
echo " inside app/phpunit.xml" | |
echo "" | |
echo "Examples:" | |
echo " Run the tests as specified inside app/phpunit.xml:" | |
echo " ./runTests.sh" | |
echo " Run the tests as specified inside app/phpunit.xml, but reset database first:" | |
echo " ./runTests.sh -r" | |
echo " Run the tests from src/AcmeBundle:" | |
echo " ./runTests.sh src/AcmeBundle" | |
echo " Run the tests from src/AcmeBundle, but reset database first:" | |
echo " ./runTests.sh -r src/AcmeBundle" | |
echo " Run only the service tests from src/AcmeBundle:" | |
echo " ./runTests.sh -r src/AcmeBundle/Tests/Service" | |
exit 0 | |
} | |
DIRECTORY="" | |
# parse command line arguments | |
for key in $@ | |
do | |
case ${key} in | |
-r|--reset) | |
php app/console doctrine:cache:clear-metadata --env=test | |
php app/console cache:clear --env=test | |
php app/console doctrine:database:drop --env=test --force | |
php app/console doctrine:database:create --env=test | |
php app/console doctrine:schema:update --env=test --force | |
;; | |
-h|--help) | |
printHelp | |
;; | |
*) | |
DIRECTORY=${key} | |
;; | |
esac | |
done | |
# load fixtures and run tests | |
echo "y" | php app/console doctrine:fixtures:load --fixtures=src/ --env=test | |
vendor/bin/phpunit -c app ${DIRECTORY} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment