1
1
<?php
2
- namespace CodeClimate \Bundle \TestReporterBundle \Command ;
3
2
4
- use CodeClimate \Bundle \TestReporterBundle \CoverageCollector ;
5
- use CodeClimate \Bundle \TestReporterBundle \ApiClient ;
3
+ namespace CodeClimate \PhpTestReporter \ConsoleCommands ;
4
+
5
+ use CodeClimate \PhpTestReporter \TestReporter \ApiClient ;
6
+ use CodeClimate \PhpTestReporter \TestReporter \CoverageCollector ;
6
7
use Symfony \Component \Console \Command \Command ;
7
8
use Symfony \Component \Console \Input \InputInterface ;
8
9
use Symfony \Component \Console \Input \InputOption ;
@@ -15,51 +16,48 @@ class TestReporterCommand extends Command
15
16
{
16
17
/**
17
18
* Path to project root directory.
18
- *
19
19
* @var string
20
20
*/
21
21
protected $ rootDir ;
22
22
23
23
/**
24
24
* {@inheritdoc}
25
- *
26
25
* @see \Symfony\Component\Console\Command\Command::configure()
27
26
*/
28
27
protected function configure ()
29
28
{
30
29
$ this
31
- ->setName ('test-reporter ' )
32
- ->setDescription ('Code Climate PHP Test Reporter ' )
33
- ->addOption (
34
- 'stdout ' ,
35
- null ,
36
- InputOption::VALUE_NONE ,
37
- 'Do not upload, print JSON payload to stdout '
38
- )
39
- ->addOption (
40
- 'coverage-report ' ,
41
- null ,
42
- InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY ,
43
- 'Location of clover style CodeCoverage report, as produced by PHPUnit \'s --coverage-clover option. ' ,
44
- array ( 'build/logs/clover.xml ' )
45
- );
30
+ ->setName ('test-reporter ' )
31
+ ->setDescription ('Code Climate PHP Test Reporter ' )
32
+ ->addOption (
33
+ 'stdout ' ,
34
+ null ,
35
+ InputOption::VALUE_NONE ,
36
+ 'Do not upload, print JSON payload to stdout '
37
+ )
38
+ ->addOption (
39
+ 'coverage-report ' ,
40
+ null ,
41
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY ,
42
+ 'Location of clover style CodeCoverage report, as produced by PHPUnit \'s --coverage-clover option. ' ,
43
+ [ 'build/logs/clover.xml ' ]
44
+ );
46
45
}
47
46
48
47
/**
49
48
* {@inheritdoc}
50
- *
51
49
* @see \Symfony\Component\Console\Command\Command::execute()
52
50
*/
53
51
protected function execute (InputInterface $ input , OutputInterface $ output )
54
52
{
55
- $ ret = 0 ;
53
+ $ ret = 0 ;
56
54
$ collector = new CoverageCollector ($ input ->getOption ('coverage-report ' ));
57
- $ json = $ collector ->collectAsJson ();
55
+ $ json = $ collector ->collectAsJson ();
58
56
59
57
if ($ input ->getOption ('stdout ' )) {
60
58
$ output ->writeln ((string )$ json );
61
59
} else {
62
- $ client = new ApiClient ();
60
+ $ client = new ApiClient ();
63
61
$ response = $ client ->send ($ json );
64
62
switch ($ response ->code ) {
65
63
case 200 :
@@ -72,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
72
70
break ;
73
71
74
72
default :
75
- $ output ->writeln ("Unexpected response: " . $ response ->code . " " . $ response ->message );
73
+ $ output ->writeln ("Unexpected response: " . $ response ->code . " " . $ response ->message );
76
74
$ output ->writeln ($ response ->body );
77
75
$ ret = 1 ;
78
76
break ;
0 commit comments