Paulund

Test Helper Function

If you work on multiple different PHP projects, some might use different testing frameworks the most common at the moment is PHPUnit and Pest. But what if you want to use the same test helper function in both projects?

You can use the following script function to make sure you only have to type the same function on every project.

function test() {
  if [ -f ./vendor/bin/pest ]; then
    ./vendor/bin/pest $1
  elif [ -f ./vendor/bin/phpunit ]; then
    ./vendor/bin/phpunit $1
  else
    echo "No test framework found, add phpunit or pest to your composer.json"
  fi
}

UpChecker

Reliable uptime monitoring and instant alerts for any website downtime.

Get 50% off forever using the code 50OFFUP.