@@ -66,6 +66,16 @@ protected function tearDown(): void
6666 putenv ('SHELL_VERBOSITY ' );
6767 unset($ _ENV ['SHELL_VERBOSITY ' ]);
6868 unset($ _SERVER ['SHELL_VERBOSITY ' ]);
69+
70+ if (\function_exists ('pcntl_signal ' )) {
71+ // We reset all signals to their default value to avoid side effects
72+ for ($ i = 1 ; $ i <= 15 ; ++$ i ) {
73+ if (9 === $ i ) {
74+ continue ;
75+ }
76+ pcntl_signal ($ i , SIG_DFL );
77+ }
78+ }
6979 }
7080
7181 public static function setUpBeforeClass (): void
@@ -509,15 +519,7 @@ public function testDontRunAlternativeNamespaceName()
509519 $ application ->setAutoExit (false );
510520 $ tester = new ApplicationTester ($ application );
511521 $ tester ->run (['command ' => 'foos:bar1 ' ], ['decorated ' => false ]);
512- $ this ->assertSame ('
513-
514- There are no commands defined in the "foos" namespace.
515-
516- Did you mean this?
517- foo
518-
519-
520- ' , $ tester ->getDisplay (true ));
522+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/application.dont_run_alternative_namespace_name.txt ' , $ tester ->getDisplay (true ));
521523 }
522524
523525 public function testCanRunAlternativeCommandName ()
@@ -1992,15 +1994,38 @@ public function testSetSignalsToDispatchEvent()
19921994 $ dispatcher = new EventDispatcher ();
19931995 $ dispatcher ->addSubscriber ($ subscriber );
19941996
1997+ // Since there is no signal handler, and by default PHP will stop even
1998+ // on SIGUSR1, we need to register a blank handler to avoid the process
1999+ // being stopped.
2000+ $ blankHandlerSignaled = false ;
2001+ pcntl_signal (\SIGUSR1 , function () use (&$ blankHandlerSignaled ) {
2002+ $ blankHandlerSignaled = true ;
2003+ });
2004+
19952005 $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
19962006 $ application ->setSignalsToDispatchEvent (\SIGUSR2 );
19972007 $ this ->assertSame (0 , $ application ->run (new ArrayInput (['signal ' ])));
19982008 $ this ->assertFalse ($ subscriber ->signaled );
2009+ $ this ->assertTrue ($ blankHandlerSignaled );
2010+
2011+ // We reset the blank handler to false to make sure it is called again
2012+ $ blankHandlerSignaled = false ;
2013+
2014+ $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
2015+ $ application ->setSignalsToDispatchEvent (\SIGUSR1 );
2016+ $ this ->assertSame (1 , $ application ->run (new ArrayInput (['signal ' ])));
2017+ $ this ->assertTrue ($ subscriber ->signaled );
2018+ $ this ->assertTrue ($ blankHandlerSignaled );
2019+
2020+ // And now we test without the blank handler
2021+ $ blankHandlerSignaled = false ;
2022+ pcntl_signal (\SIGUSR1 , SIG_DFL );
19992023
20002024 $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
20012025 $ application ->setSignalsToDispatchEvent (\SIGUSR1 );
20022026 $ this ->assertSame (1 , $ application ->run (new ArrayInput (['signal ' ])));
20032027 $ this ->assertTrue ($ subscriber ->signaled );
2028+ $ this ->assertFalse ($ blankHandlerSignaled );
20042029 }
20052030
20062031 public function testSignalableCommandInterfaceWithoutSignals ()
0 commit comments