8
8
use Symfony \Component \Console \Command \Command ;
9
9
use Symfony \Component \Console \Input \InputArgument ;
10
10
use Symfony \Component \Console \Input \InputInterface ;
11
+ use Symfony \Component \Console \Input \InputOption ;
11
12
use Symfony \Component \Console \Output \OutputInterface ;
12
13
13
14
/**
@@ -22,10 +23,16 @@ class DevTestsRunCommand extends Command
22
23
*/
23
24
const INPUT_ARG_TYPE = 'type ' ;
24
25
26
+ /**
27
+ * PHPUnit arguments parameter
28
+ */
29
+ const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments ' ;
30
+ const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c ' ;
31
+
25
32
/**
26
33
* command name
27
34
*/
28
- const COMMAND_NAME = 'dev:tests:run ' ;
35
+ const COMMAND_NAME = 'dev:tests:run ' ;
29
36
30
37
/**
31
38
* Maps types (from user input) to phpunit test names
@@ -56,6 +63,13 @@ protected function configure()
56
63
'Type of test to run. Available types: ' . implode (', ' , array_keys ($ this ->types )),
57
64
'default '
58
65
);
66
+ $ this ->addOption (
67
+ self ::INPUT_OPT_COMMAND_ARGUMENTS ,
68
+ self ::INPUT_OPT_COMMAND_ARGUMENTS_SHORT ,
69
+ InputOption::VALUE_REQUIRED ,
70
+ 'Additional arguments for PHPUnit. Example: "-c \'--filter=MyTest \'" (no spaces) ' ,
71
+ ''
72
+ );
59
73
60
74
parent ::configure ();
61
75
}
@@ -87,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
87
101
$ dirName = realpath (BP . '/dev/tests/ ' . $ dir );
88
102
chdir ($ dirName );
89
103
$ command = PHP_BINARY . ' ' . BP . '/ ' . $ vendorDir . '/phpunit/phpunit/phpunit ' . $ options ;
104
+ if ($ commandArguments = $ input ->getOption (self ::INPUT_OPT_COMMAND_ARGUMENTS )) {
105
+ $ command .= ' ' . $ commandArguments ;
106
+ }
90
107
$ message = $ dirName . '> ' . $ command ;
91
108
$ output ->writeln (['' , str_pad ("---- {$ message } " , 70 , '- ' ), '' ]);
92
109
passthru ($ command , $ returnVal );
0 commit comments