8 use Symfony\Component\Console\Command\Command;
9 use Symfony\Component\Console\Input\InputArgument;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Output\OutputInterface;
56 $this->setupTestInfo();
57 $this->setName(self::COMMAND_NAME)
58 ->setDescription(
'Runs tests');
62 InputArgument::OPTIONAL,
63 'Type of test to run. Available types: ' . implode(
', ', array_keys($this->types)),
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)',
86 $type = $input->getArgument(self::INPUT_ARG_TYPE);
87 if (!isset($this->types[
$type])) {
89 'Invalid type: "' .
$type .
'". Available types: ' . implode(
', ', array_keys($this->types))
97 $runCommands = $this->types[
$type];
98 foreach ($runCommands as $key) {
99 list($dir,
$options) = $this->commands[$key];
100 $dirName = realpath(
BP .
'/dev/tests/' . $dir);
103 if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) {
104 $command .=
' ' . $commandArguments;
106 $message = $dirName .
'> ' . $command;
107 $output->writeln([
'', str_pad(
"---- {$message} ", 70,
'-'),
'']);
114 $output->writeln(str_repeat(
'-', 70));
116 $output->writeln(
"FAILED - " . count($failures) .
' of ' . count($runCommands) .
":");
121 return \Magento\Framework\Console\Cli::RETURN_FAILURE;
123 $output->writeln(
'PASSED (' . count($runCommands) .
')');
125 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
133 private function setupTestInfo()
136 'unit' => [
'../tests/unit',
''],
137 'unit-static' => [
'../tests/static/framework/tests/unit',
''],
138 'unit-integration' => [
'../tests/integration/framework/tests/unit',
''],
139 'integration' => [
'../tests/integration',
''],
140 'integration-integrity' => [
'../tests/integration',
' testsuite/Magento/Test/Integrity'],
141 'static-default' => [
'../tests/static',
''],
142 'static-legacy' => [
'../tests/static',
' testsuite/Magento/Test/Legacy'],
143 'static-integration-js' => [
'../tests/static',
' testsuite/Magento/Test/Js/Exemplar'],
146 'all' => array_keys($this->commands),
147 'unit' => [
'unit',
'unit-static',
'unit-integration'],
148 'integration' => [
'integration'],
149 'integration-all' => [
'integration',
'integration-integrity'],
150 'static' => [
'static-default'],
151 'static-all' => [
'static-default',
'static-legacy',
'static-integration-js'],
152 'integrity' => [
'static-default',
'static-legacy',
'integration-integrity'],
153 'legacy' => [
'static-legacy'],
if(!file_exists(VENDOR_PATH)) $vendorDir
const INPUT_OPT_COMMAND_ARGUMENTS
execute(InputInterface $input, OutputInterface $output)
passthru($command, &$return_var=null)
const INPUT_OPT_COMMAND_ARGUMENTS_SHORT