|
63 | 63 | use Symfony\Component\Console\Command\ListCommand; |
64 | 64 | use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; |
65 | 65 | use Symfony\Component\Console\Input\ArrayInput; |
| 66 | +use Symfony\Component\Console\Input\InputOption; |
66 | 67 | use Symfony\Component\Console\Input\InputInterface; |
67 | 68 | use Symfony\Component\Console\Output\OutputInterface; |
68 | 69 | use Symfony\Component\Console\Output\BufferedOutput; |
@@ -271,6 +272,96 @@ public function doRunWillNotRenderLogoWhenNoLogoOptionIsSet(): void |
271 | 272 | self::assertStringNotContainsString('_____', $output->fetch()); |
272 | 273 | } |
273 | 274 |
|
| 275 | + /** |
| 276 | + * @return void |
| 277 | + */ |
| 278 | + #[Test] |
| 279 | + public function doRunWillNotRenderLogoWhenJsonOptionIsProvided(): void |
| 280 | + { |
| 281 | + $command = new class extends Command { |
| 282 | + public function __construct() |
| 283 | + { |
| 284 | + parent::__construct('standards'); |
| 285 | + } |
| 286 | + |
| 287 | + protected function configure(): void |
| 288 | + { |
| 289 | + $this->addOption(name: 'json', mode: InputOption::VALUE_NONE, description: 'Emit structured JSON output.'); |
| 290 | + $this->setCode(static fn(InputInterface $input, OutputInterface $output): int => Command::SUCCESS); |
| 291 | + } |
| 292 | + }; |
| 293 | + |
| 294 | + $this->commandLoader->has('standards') |
| 295 | + ->willReturn(true) |
| 296 | + ->shouldBeCalledOnce(); |
| 297 | + $this->commandLoader->get('standards') |
| 298 | + ->willReturn($command) |
| 299 | + ->shouldBeCalledOnce(); |
| 300 | + $input = new ArrayInput([ |
| 301 | + 'command' => 'standards', |
| 302 | + '--json' => true, |
| 303 | + ]); |
| 304 | + |
| 305 | + $output = new BufferedOutput(); |
| 306 | + |
| 307 | + $this->environment->get('FAST_FORWARD_AUTO_UPDATE', '') |
| 308 | + ->willReturn(''); |
| 309 | + $this->workingDirectorySwitcher->switchTo(null) |
| 310 | + ->shouldBeCalledOnce(); |
| 311 | + $this->versionCheckNotifier->notify($output) |
| 312 | + ->shouldNotBeCalled(); |
| 313 | + |
| 314 | + $result = $this->invokeDoRun($input, $output); |
| 315 | + |
| 316 | + self::assertSame(Command::SUCCESS, $result); |
| 317 | + self::assertStringNotContainsString('_____', $output->fetch()); |
| 318 | + } |
| 319 | + |
| 320 | + /** |
| 321 | + * @return void |
| 322 | + */ |
| 323 | + #[Test] |
| 324 | + public function doRunWillNotRenderLogoWhenPrettyJsonOptionIsProvided(): void |
| 325 | + { |
| 326 | + $command = new class extends Command { |
| 327 | + public function __construct() |
| 328 | + { |
| 329 | + parent::__construct('standards'); |
| 330 | + } |
| 331 | + |
| 332 | + protected function configure(): void |
| 333 | + { |
| 334 | + $this->addOption(name: 'pretty-json', mode: InputOption::VALUE_NONE, description: 'Emit pretty JSON output.'); |
| 335 | + $this->setCode(static fn(InputInterface $input, OutputInterface $output): int => Command::SUCCESS); |
| 336 | + } |
| 337 | + }; |
| 338 | + |
| 339 | + $this->commandLoader->has('standards') |
| 340 | + ->willReturn(true) |
| 341 | + ->shouldBeCalledOnce(); |
| 342 | + $this->commandLoader->get('standards') |
| 343 | + ->willReturn($command) |
| 344 | + ->shouldBeCalledOnce(); |
| 345 | + $input = new ArrayInput([ |
| 346 | + 'command' => 'standards', |
| 347 | + '--pretty-json' => true, |
| 348 | + ]); |
| 349 | + |
| 350 | + $output = new BufferedOutput(); |
| 351 | + |
| 352 | + $this->environment->get('FAST_FORWARD_AUTO_UPDATE', '') |
| 353 | + ->willReturn(''); |
| 354 | + $this->workingDirectorySwitcher->switchTo(null) |
| 355 | + ->shouldBeCalledOnce(); |
| 356 | + $this->versionCheckNotifier->notify($output) |
| 357 | + ->shouldNotBeCalled(); |
| 358 | + |
| 359 | + $result = $this->invokeDoRun($input, $output); |
| 360 | + |
| 361 | + self::assertSame(Command::SUCCESS, $result); |
| 362 | + self::assertStringNotContainsString('_____', $output->fetch()); |
| 363 | + } |
| 364 | + |
274 | 365 | /** |
275 | 366 | * @return void |
276 | 367 | */ |
|
0 commit comments