Skip to content

Instantly share code, notes, and snippets.

@seignovert
Created January 20, 2018 15:18
Show Gist options
  • Save seignovert/8da2143372dcc5f68aa9c02ec43a2335 to your computer and use it in GitHub Desktop.
Save seignovert/8da2143372dcc5f68aa9c02ec43a2335 to your computer and use it in GitHub Desktop.
[Symfony 4] PHP Unit pre-commit
#!/usr/bin/env php
<?php
$projectName = basename(getcwd());
exec('php bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
$minimalTestSummary = array_pop($output);
printf("Test suite for %s failed: ", $projectName);
printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL);
printf("ABORTING COMMIT!\n");
exit(1);
}
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment