Skip to content

Commit 528ec17

Browse files
moonrakingBertrandF23
authored andcommitted
Smoketest command, expose getTestNames, add option to command to list test name (#8)
1 parent 967b906 commit 528ec17

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

Command/SmokeTestRunCommand.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class SmokeTestRunCommand extends ContainerAwareCommand
1717
/** @var SmokeTestInterface[] */
1818
protected $smokeTests = [];
1919

20-
/** @var InputInterface */
20+
/** @var InputInterface */
2121
protected $in;
2222

23-
/** @var OutputInterface */
23+
/** @var OutputInterface */
2424
protected $out;
2525

2626
protected function configure()
@@ -51,6 +51,7 @@ protected function configure()
5151
)
5252
->addOption('json', null, InputOption::VALUE_NONE, 'Show output in JSON format.')
5353
->addOption('output', null, InputOption::VALUE_REQUIRED, 'File path to write')
54+
->addOption('list', 'L', InputOption::VALUE_NONE, 'List all the possible tests')
5455
->addArgument('test', InputArgument::OPTIONAL, 'Specify the id of a single test to execute');
5556
}
5657

@@ -102,10 +103,19 @@ protected function execute(InputInterface $in, OutputInterface $out)
102103
$skipped = [];
103104
$smokeTests = $this->smokeTests;
104105

106+
if ($in->getOption('list')) {
107+
$testNames = $this->getTestNames();
108+
foreach ($testNames as $name) {
109+
$this->out->writeln($name);
110+
}
111+
112+
return 0;
113+
}
114+
105115
if ($test) {
106116
// executes a single test
107117
$showSkipped = false;
108-
$testNames = array_keys($smokeTests);
118+
$testNames = $this->getTestNames();
109119
$smokeTests = array_filter(
110120
$smokeTests,
111121
function ($key) use ($test) {
@@ -321,4 +331,14 @@ protected function applyOutputStyles()
321331
new OutputFormatterStyle('yellow')
322332
);
323333
}
334+
335+
/**
336+
* Returns and array of all the test names that this command can run.
337+
*
338+
* @return array
339+
*/
340+
public function getTestNames()
341+
{
342+
return array_keys($this->smokeTests);
343+
}
324344
}

0 commit comments

Comments
 (0)