diff --git a/src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php b/src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php index 66edec9e..18e20173 100644 --- a/src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php @@ -5,6 +5,7 @@ namespace Codeception\Module\Symfony; use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\HttpKernel\KernelInterface; @@ -33,8 +34,10 @@ public function runSymfonyConsoleCommand(string $command, array $parameters = [] $commandTester = new CommandTester($consoleCommand); $commandTester->setInputs($consoleInputs); - $parameters = ['command' => $command] + $parameters; - $exitCode = $commandTester->execute($parameters); + $input = ['command' => $command] + $parameters; + $options = $this->configureOptions($parameters); + + $exitCode = $commandTester->execute($input, $options); $output = $commandTester->getDisplay(); $this->assertSame( @@ -51,6 +54,49 @@ public function runSymfonyConsoleCommand(string $command, array $parameters = [] return $output; } + private function configureOptions(array $parameters): array + { + $options = []; + + if (in_array('--ansi', $parameters, true)) { + $options['decorated'] = true; + } elseif (in_array('--no-ansi', $parameters, true)) { + $options['decorated'] = false; + } + + if (in_array('--no-interaction', $parameters, true) || in_array('-n', $parameters, true)) { + $options['interactive'] = false; + } + + if (in_array('--quiet', $parameters, true) || in_array('-q', $parameters, true)) { + $options['verbosity'] = OutputInterface::VERBOSITY_QUIET; + $options['interactive'] = false; + } + + if ( + in_array('-vvv', $parameters, true) || + in_array('--verbose=3', $parameters, true) || + (isset($parameters["--verbose"]) && $parameters["--verbose"] === 3) + ) { + $options['verbosity'] = OutputInterface::VERBOSITY_DEBUG; + } elseif ( + in_array('-vv', $parameters, true) || + in_array('--verbose=2', $parameters, true) || + (isset($parameters["--verbose"]) && $parameters["--verbose"] === 2) + ) { + $options['verbosity'] = OutputInterface::VERBOSITY_VERY_VERBOSE; + } elseif ( + in_array('-v', $parameters, true) || + in_array('--verbose=1', $parameters, true) || + in_array('--verbose', $parameters, true) || + (isset($parameters["--verbose"]) && $parameters["--verbose"] === 1) + ) { + $options['verbosity'] = OutputInterface::VERBOSITY_VERBOSE; + } + + return $options; + } + protected function grabKernelService(): KernelInterface { return $this->grabService('kernel'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy