phpunit.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. if [ "$1" == 'full' ]; then
  3. fulltest=1
  4. elif [ "$1" == 'each' ]; then
  5. testeach=1
  6. else
  7. fulltest=0
  8. fi
  9. PHP_VERSION=$(php -r "echo PHP_VERSION_ID;")
  10. echo
  11. echo -e "\033[33mBegin Unit Testing\033[0m"
  12. # Run the testing suite
  13. echo "Basic test suite:"
  14. php vendor/bin/phpunit tests/unit
  15. if [ $? -ne 0 ]; then
  16. # Test failure
  17. exit 1
  18. fi
  19. echo "With open_basedir enabled:"
  20. php -d open_basedir=`pwd` vendor/bin/phpunit tests/unit
  21. if [ $? -ne 0 ]; then
  22. # Test failure
  23. exit 1
  24. fi
  25. echo "With open_basedir enabled, allowing /dev:"
  26. php -d open_basedir=`pwd`:/dev vendor/bin/phpunit tests/unit
  27. if [ $? -ne 0 ]; then
  28. # Test failure
  29. exit 1
  30. fi
  31. echo "With mbstring.func_overload enabled:"
  32. php -d mbstring.func_overload=7 vendor/bin/phpunit tests/unit
  33. if [ $? -ne 0 ]; then
  34. # Test failure
  35. exit 1
  36. fi
  37. if [[ "$testeach" == "1" ]]; then
  38. echo " CAPICOM:"
  39. php vendor/bin/phpunit --bootstrap tests/specific/capicom.php tests/unit
  40. echo " /dev/urandom:"
  41. php vendor/bin/phpunit --bootstrap tests/specific/dev_urandom.php tests/unit
  42. echo " libsodium:"
  43. php vendor/bin/phpunit --bootstrap tests/specific/libsodium.php tests/unit
  44. echo " mcrypt:"
  45. php vendor/bin/phpunit --bootstrap tests/specific/mcrypt.php tests/unit
  46. echo " openssl:"
  47. php vendor/bin/phpunit --bootstrap tests/specific/openssl.php tests/unit
  48. fi
  49. # Should we perform full statistical analyses?
  50. if [[ "$fulltest" == "1" ]]; then
  51. php vendor/bin/phpunit tests/full
  52. if [ $? -ne 0 ]; then
  53. # Test failure
  54. exit 1
  55. fi
  56. fi