|
45 | 45 | use Symfony\Component\Console\SignalRegistry\SignalRegistry;
|
46 | 46 | use Symfony\Component\Console\Terminal;
|
47 | 47 | use Symfony\Component\Console\Tester\ApplicationTester;
|
| 48 | +use Symfony\Component\Console\Tests\Fixtures\AsCommandExtended; |
48 | 49 | use Symfony\Component\Console\Tests\Fixtures\MockableAppliationWithTerminalWidth;
|
49 | 50 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
50 | 51 | use Symfony\Component\EventDispatcher\EventDispatcher;
|
@@ -559,6 +560,16 @@ public function testDontRunAlternativeCommandName()
|
559 | 560 | $this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
|
560 | 561 | }
|
561 | 562 |
|
| 563 | + public function testExtendedAsCommandAtribute() |
| 564 | + { |
| 565 | + $application = new Application(); |
| 566 | + $application->add(new WithExtendedAttributeCommand()); |
| 567 | + $application->setAutoExit(false); |
| 568 | + $tester = new ApplicationTester($application); |
| 569 | + $exitCode = $tester->run(['command' => 'withExtendedAttribute']); |
| 570 | + $this->assertSame(Command::FAILURE, $exitCode); |
| 571 | + } |
| 572 | + |
562 | 573 | public static function provideInvalidCommandNamesSingle()
|
563 | 574 | {
|
564 | 575 | return [
|
@@ -2642,3 +2653,11 @@ public static function getSubscribedEvents(): array
|
2642 | 2653 | return [ConsoleAlarmEvent::class => 'onAlarm'];
|
2643 | 2654 | }
|
2644 | 2655 | }
|
| 2656 | + |
| 2657 | +#[AsCommandExtended(name: 'withExtendedAttribute', addedParam: 'addedParam')] |
| 2658 | +class WithExtendedAttributeCommand extends Command { |
| 2659 | + protected function execute(InputInterface $input, OutputInterface $output): int |
| 2660 | + { |
| 2661 | + return Command::FAILURE; |
| 2662 | + } |
| 2663 | +} |
0 commit comments