99use Prophecy \Argument ;
1010use Prophecy \PhpUnit \ProphecyTrait ;
1111use Symfony \Bridge \PhpUnit \ClockMock ;
12+ use Symfony \Component \Console \Command \SignalableCommandInterface ;
1213use Symfony \Component \Console \Input \ArrayInput ;
1314use Symfony \Component \Console \Input \InputInterface ;
1415use Symfony \Component \Console \Output \OutputInterface ;
@@ -117,12 +118,7 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
117118 */
118119 public function testReceiveSignalBeforeCommandBody (int $ signal ): void
119120 {
120- $ stubCommand = new class ('dummy:command ' ) extends AbstractTerminableCommand {
121- protected function commandBody (InputInterface $ input , OutputInterface $ output ): int
122- {
123- return 0 ;
124- }
125- };
121+ $ stubCommand = $ this ->createStubTerminableCommand ();
126122
127123 $ output = $ this ->prophesize (OutputInterface::class);
128124 $ output ->writeln (Argument::containingString ('Starting ' ), OutputInterface::VERBOSITY_VERBOSE )
@@ -138,6 +134,17 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
138134 $ this ->assertSame (143 , $ exitCode );
139135 }
140136
137+ public function testGetSubscribedSignals (int $ signal ): void
138+ {
139+ $ stubCommand = $ this ->createStubTerminableCommand ();
140+
141+ if (! class_exists (SignalableCommandInterface::class) || ! $ stubCommand instanceof SignalableCommandInterface) {
142+ $ this ->markTestSkipped ('This test requires the Symfony 7.3+ implementation ' );
143+ }
144+
145+ $ this ->assertContains ($ signal , $ stubCommand ->getSubscribedSignals (), 'Signal not subscribed to ' );
146+ }
147+
141148 /**
142149 * @return array{0: int}[]
143150 */
@@ -148,4 +155,14 @@ public function signalProvider(): array
148155 [SIGTERM ],
149156 ];
150157 }
158+
159+ private function createStubTerminableCommand (): AbstractTerminableCommand
160+ {
161+ return new class ('dummy:command ' ) extends AbstractTerminableCommand {
162+ protected function commandBody (InputInterface $ input , OutputInterface $ output ): int
163+ {
164+ return 0 ;
165+ }
166+ };
167+ }
151168}
0 commit comments