Skip to content

Instantly share code, notes, and snippets.

@treetop1500
Created September 4, 2018 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treetop1500/5a00d29f67451fb76531b3c77983e74b to your computer and use it in GitHub Desktop.
Save treetop1500/5a00d29f67451fb76531b3c77983e74b to your computer and use it in GitHub Desktop.
Git pre-commit hook for running phpunit functional and unit tests.
#!/usr/local/bin/php
<?php
echo "Running tests.. ";
exec('bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
// Show full output
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
echo "Aborting commit.." . PHP_EOL;
exit(1);
}
// Show summary (last line)
echo array_pop($output) . PHP_EOL;
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment