|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bob\BuildConfig; |
|
4
|
|
|
|
|
5
|
|
|
task('default', ['test', 'phpstan', 'sniff']); |
|
6
|
|
|
|
|
7
|
|
|
desc('Run all tests'); |
|
8
|
|
|
task('test', ['phpspec' , 'behat', 'examples']); |
|
9
|
|
|
|
|
10
|
|
|
desc('Run phpspec unit tests'); |
|
11
|
|
|
task('phpspec', function() { |
|
12
|
|
|
shell('phpspec run'); |
|
13
|
|
|
println('Phpspec unit tests passed'); |
|
14
|
|
|
}); |
|
15
|
|
|
|
|
16
|
|
|
desc('Run behat feature tests'); |
|
17
|
|
|
task('behat', function() { |
|
18
|
|
|
shell('behat --stop-on-failure'); |
|
19
|
|
|
println('Behat feature tests passed'); |
|
20
|
|
|
}); |
|
21
|
|
|
|
|
22
|
|
|
desc('Test examples'); |
|
23
|
|
|
task('examples', function() { |
|
24
|
|
|
shell('readme-tester README.md'); |
|
25
|
|
|
println('Examples passed'); |
|
26
|
|
|
}); |
|
27
|
|
|
|
|
28
|
|
|
desc('Run statical analysis using phpstan'); |
|
29
|
|
|
task('phpstan', function() { |
|
30
|
|
|
shell('phpstan analyze -c phpstan.neon -l 7 src'); |
|
31
|
|
|
println('Phpstan analysis passed'); |
|
32
|
|
|
}); |
|
33
|
|
|
|
|
34
|
|
|
desc('Run php code sniffer'); |
|
35
|
|
|
task('sniff', function() { |
|
36
|
|
|
shell('phpcs src --standard=PSR2 --ignore=router_template.php'); |
|
37
|
|
|
println('Syntax checker on src/ done'); |
|
38
|
|
|
shell('phpcs spec --standard=spec/ruleset.xml'); |
|
39
|
|
|
println('Syntax checker on spec/ done'); |
|
40
|
|
|
}); |
|
41
|
|
|
|
|
42
|
|
|
desc('Globally install development tools'); |
|
43
|
|
|
task('install_dev_tools', function() { |
|
44
|
|
|
shell('composer global require consolidation/cgr'); |
|
45
|
|
|
shell('cgr phpspec/phpspec'); |
|
46
|
|
|
shell('cgr behat/behat'); |
|
47
|
|
|
shell('cgr phpstan/phpstan'); |
|
48
|
|
|
shell('cgr squizlabs/php_codesniffer'); |
|
49
|
|
|
shell('cgr hanneskod/readme-tester:^1.0@beta'); |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
function shell(string $command) |
|
53
|
|
|
{ |
|
54
|
|
|
return sh($command, null, ['failOnError' => true]); |
|
55
|
|
|
} |
|
56
|
|
|
|