@@ -12,13 +12,56 @@ class CheckCommand extends AbstractCommand
1212 protected function configure ()
1313 {
1414 $ this ->setName ('check ' )
15- ->addOption ('report ' , null , InputOption::VALUE_NONE , 'Send coverage report? ' )
16- ->addOption ('coverage-text ' , null , InputOption::VALUE_NONE , 'Display coverage info? ' )
17- ->addOption ('coverage-html ' , null , InputOption::VALUE_OPTIONAL , 'Save coverage info as HTML? ' , false )
18- ->addOption ('coverage-clover ' , null , InputOption::VALUE_OPTIONAL , 'Save coverage info as XML? ' , false )
19- ->addOption ('group ' , null , InputOption::VALUE_OPTIONAL , 'Excute only a tests group? ' , false )
20- ->addOption ('ignore-tests ' , null , InputOption::VALUE_NONE , 'Ignore /tests/ directories ' )
21- ->addOption ('ignore-debug ' , null , InputOption::VALUE_NONE , 'Ignore /debug/ directories ' )
15+ ->addOption ('report ' ,
16+ null ,
17+ InputOption::VALUE_NONE ,
18+ 'Send coverage report? '
19+ )
20+ ->addOption (
21+ 'coverage-text ' ,
22+ null ,
23+ InputOption::VALUE_NONE ,
24+ 'Display coverage info? '
25+ )
26+ ->addOption (
27+ 'coverage-html ' ,
28+ null ,
29+ InputOption::VALUE_OPTIONAL ,
30+ 'Save coverage info as HTML? ' ,
31+ false
32+ )
33+ ->addOption (
34+ 'coverage-clover ' ,
35+ null ,
36+ InputOption::VALUE_OPTIONAL ,
37+ 'Save coverage info as XML? ' ,
38+ false
39+ )
40+ ->addOption (
41+ 'group ' ,
42+ null ,
43+ InputOption::VALUE_OPTIONAL ,
44+ 'Excute only a tests group? ' ,
45+ false
46+ )
47+ ->addOption (
48+ 'ignore-tests ' ,
49+ null ,
50+ InputOption::VALUE_NONE ,
51+ 'Ignore /tests/ directories '
52+ )
53+ ->addOption (
54+ 'ignore-debug ' ,
55+ null ,
56+ InputOption::VALUE_NONE ,
57+ 'Ignore /debug/ directories '
58+ )
59+ ->addOption (
60+ 'coverage-php-version ' ,
61+ null ,
62+ InputOption::VALUE_OPTIONAL ,
63+ 'If specified, the coverage is only tested for the given PHP version '
64+ )
2265 ->setDescription ('Runs all necessary checks. ' )
2366 ->setHelp ('Runs all necessary checks ' );
2467 }
@@ -27,15 +70,31 @@ protected function runCoverage(InputInterface $input, OutputInterface $output, $
2770 {
2871 $ app = $ this ->getApplication ();
2972
73+ $ phpVersion = $ input ->getOption ('coverage-php-version ' );
74+
75+ if (!empty ($ phpVersion )) {
76+ if (!preg_match ('/^ ' .preg_quote ($ phpVersion ).'(\D.*)?$/ ' , PHP_VERSION )) {
77+ $ output ->writeln (
78+ 'Coverage ignored since PHP version ( ' .PHP_VERSION .') ' .
79+ ' does not match ' .$ phpVersion .'. '
80+ );
81+
82+ return 0 ;
83+ }
84+ $ output ->writeln (
85+ '<fg=green>Proceed test report since PHP version ( ' .PHP_VERSION .') ' .
86+ 'matches ' .$ phpVersion .'.</> '
87+ );
88+ }
89+
3090 if (($ code = $ app ->runCommand ('coverage:check ' , $ output , [
3191 'input-file ' => $ coverageFilePath ,
3292 ])) !== 0 ) {
3393 return $ code ;
3494 }
3595
36- if ($ input -> getOption ( ' report ' ) && ($ code = $ app ->runCommand ('coverage:report ' , $ output , [
96+ if (($ code = $ app ->runCommand ('coverage:report ' , $ output , [
3797 'input-file ' => $ coverageFilePath ,
38- 'php-version ' => '5.6 ' ,
3998 ])) !== 0 ) {
4099 return $ code ;
41100 }
0 commit comments