Skip to content

Instantly share code, notes, and snippets.

@fokosun
Last active May 23, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fokosun/49f33f683728ec6c4221cbfb4ecbeb41 to your computer and use it in GitHub Desktop.
Save fokosun/49f33f683728ec6c4221cbfb4ecbeb41 to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
$projectName = basename(getcwd()); // get the name of your app
echo PHP_EOL;
echo '+ Starting unit tests'.PHP_EOL;
exec('vendor/bin/phpunit', $output, $returnCode); // command to run tests with any testing framework you like
if ($returnCode !== 0) {
$testSummary = $output;
printf("%s Test Summary: ", $projectName);
echo PHP_EOL;
printf("( %s ) %s%2\$s", $testSummary[14], PHP_EOL);
printf("ABORTING COMMIT!\n");
exit(1); // git halts
}
exit(0); // git continues with push event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment