Skip to content

Commit e672074

Browse files
committed
add git-hooks for codeception tests and dev libraries mockery and IDE helper (like PhpStorm)
1 parent 1f46ab3 commit e672074

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
},
1212
"require-dev": {
1313
"codeception/codeception": "2.3.x-dev",
14+
"mockery/mockery": "1.0",
15+
"barryvdh/laravel-ide-helper": "2.4.1",
1416
"symfony/dom-crawler": "~3.0",
1517
"symfony/css-selector": "~3.0"
1618
},
@@ -19,7 +21,8 @@
1921
"database"
2022
],
2123
"psr-4": {
22-
"App\\": "app/"
24+
"App\\": "app/",
25+
"Tests\\": "tests/"
2326
}
2427
},
2528
"autoload-dev": {

git-hooks/pre-commit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$projectName = basename(getcwd());
5+
6+
exec('vendor\bin\codecept run --no-colors -n --html', $output, $returnCode);
7+
8+
if ($returnCode !== 0) {
9+
$html = array_pop($output);
10+
$minimalTestSummary = array_pop($output);
11+
printf("Codeception Test suite for %s failed: ", $projectName);
12+
printf("( %s ) %s", $minimalTestSummary, PHP_EOL);
13+
printf("%s %s", $html, PHP_EOL);
14+
printf("ABORTING Push!\n");
15+
exit(1);
16+
} else {
17+
printf("Codeception tests are successful!\n");
18+
}
19+
20+
exit(0);

git-hooks/pre-push

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$projectName = basename(getcwd());
5+
6+
exec('vendor\bin\codecept run --no-colors -n --html', $output, $returnCode);
7+
8+
if ($returnCode !== 0) {
9+
$html = array_pop($output);
10+
$minimalTestSummary = array_pop($output);
11+
printf("Codeception Test suite for %s failed: ", $projectName);
12+
printf("( %s ) %s", $minimalTestSummary, PHP_EOL);
13+
printf("%s %s", $html, PHP_EOL);
14+
printf("ABORTING Push!\n");
15+
exit(1);
16+
} else {
17+
printf("Codeception tests are successful!\n");
18+
}
19+
20+
exit(0);

0 commit comments

Comments
 (0)