setDescription('Executa testes automatizados para um módulo específico') ->addArgument('name', InputArgument::REQUIRED, 'Nome do módulo'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $moduleName = strtolower($input->getArgument('name')); $modulePath = dirname(dirname(dirname(__DIR__))) . '/modules/' . $moduleName; if (!is_dir($modulePath)) { $io->error("Módulo '{$moduleName}' não encontrado em {$modulePath}"); return Command::FAILURE; } $testPath = $modulePath . '/tests'; if (!is_dir($testPath)) { $io->warning("O módulo '{$moduleName}' não possui uma pasta de testes em {$testPath}."); return Command::INVALID; } $io->title("Iniciando testes para o módulo: " . ucfirst($moduleName)); // Execute PHPUnit pointing to the module's test directory // Using vendor/bin/phpunit which is standard for the project $phpunitExec = dirname(dirname(dirname(__DIR__))) . '/vendor/bin/phpunit'; // We use the full path to phpunit to avoid command not found issues $command = "php \"{$phpunitExec}\" \"{$testPath}\""; $io->note("Executando: {$command}"); passthru($command, $exitCode); if ($exitCode === 0) { $io->success("Todos os testes do módulo '{$moduleName}' passaram!"); } else { $io->error("Falha nos testes do módulo '{$moduleName}'."); } return $exitCode === 0 ? Command::SUCCESS : Command::FAILURE; } }