@@ -64,6 +64,16 @@ protected function tearDown(): void
6464 putenv ('SHELL_VERBOSITY ' );
6565 unset($ _ENV ['SHELL_VERBOSITY ' ]);
6666 unset($ _SERVER ['SHELL_VERBOSITY ' ]);
67+
68+ if (\function_exists ('pcntl_signal ' )) {
69+ // We reset all signals to their default value to avoid side effects
70+ for ($ i = 1 ; $ i <= 15 ; ++$ i ) {
71+ if (9 === $ i ) {
72+ continue ;
73+ }
74+ pcntl_signal ($ i , SIG_DFL );
75+ }
76+ }
6777 }
6878
6979 public static function setUpBeforeClass (): void
@@ -508,15 +518,7 @@ public function testDontRunAlternativeNamespaceName()
508518 $ application ->setAutoExit (false );
509519 $ tester = new ApplicationTester ($ application );
510520 $ tester ->run (['command ' => 'foos:bar1 ' ], ['decorated ' => false ]);
511- $ this ->assertSame ('
512-
513- There are no commands defined in the "foos" namespace.
514-
515- Did you mean this?
516- foo
517-
518-
519- ' , $ tester ->getDisplay (true ));
521+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/application.dont_run_alternative_namespace_name.txt ' , $ tester ->getDisplay (true ));
520522 }
521523
522524 public function testCanRunAlternativeCommandName ()
@@ -1956,15 +1958,38 @@ public function testSetSignalsToDispatchEvent()
19561958 $ dispatcher = new EventDispatcher ();
19571959 $ dispatcher ->addSubscriber ($ subscriber );
19581960
1961+ // Since there is no signal handler, and by default PHP will stop even
1962+ // on SIGUSR1, we need to register a blank handler to avoid the process
1963+ // being stopped.
1964+ $ blankHandlerSignaled = false ;
1965+ pcntl_signal (\SIGUSR1 , function () use (&$ blankHandlerSignaled ) {
1966+ $ blankHandlerSignaled = true ;
1967+ });
1968+
19591969 $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
19601970 $ application ->setSignalsToDispatchEvent (\SIGUSR2 );
19611971 $ this ->assertSame (0 , $ application ->run (new ArrayInput (['signal ' ])));
19621972 $ this ->assertFalse ($ subscriber ->signaled );
1973+ $ this ->assertTrue ($ blankHandlerSignaled );
1974+
1975+ // We reset the blank handler to false to make sure it is called again
1976+ $ blankHandlerSignaled = false ;
1977+
1978+ $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
1979+ $ application ->setSignalsToDispatchEvent (\SIGUSR1 );
1980+ $ this ->assertSame (1 , $ application ->run (new ArrayInput (['signal ' ])));
1981+ $ this ->assertTrue ($ subscriber ->signaled );
1982+ $ this ->assertTrue ($ blankHandlerSignaled );
1983+
1984+ // And now we test without the blank handler
1985+ $ blankHandlerSignaled = false ;
1986+ pcntl_signal (\SIGUSR1 , SIG_DFL );
19631987
19641988 $ application = $ this ->createSignalableApplication ($ command , $ dispatcher );
19651989 $ application ->setSignalsToDispatchEvent (\SIGUSR1 );
19661990 $ this ->assertSame (1 , $ application ->run (new ArrayInput (['signal ' ])));
19671991 $ this ->assertTrue ($ subscriber ->signaled );
1992+ $ this ->assertFalse ($ blankHandlerSignaled );
19681993 }
19691994
19701995 public function testSignalableCommandInterfaceWithoutSignals ()
0 commit comments