Skip to content

Instantly share code, notes, and snippets.

@barryvdh
Created November 2, 2016 12:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save barryvdh/16db6b5063f1407f87771078333ae1df to your computer and use it in GitHub Desktop.
Save barryvdh/16db6b5063f1407f87771078333ae1df to your computer and use it in GitHub Desktop.
Git pre-push hook for PHPUnit
#!/usr/bin/env php
<?php
echo "Running tests.. ";
exec('vendor/bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
// Show full output
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
echo "Cannot push changes untill tests are OK.." . PHP_EOL;
exit(1);
}
// Show summary (last line)
echo array_pop($output) . PHP_EOL;
exit(0);
@hoffmann-andras
Copy link

implode(PHP_EOL, $output)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment