@@ -64,6 +64,16 @@ protected function tearDown(): void
|
64 | 64 | putenv('SHELL_VERBOSITY');
|
65 | 65 | unset($_ENV['SHELL_VERBOSITY']);
|
66 | 66 | 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 | +} |
67 | 77 | }
|
68 | 78 |
|
69 | 79 | public static function setUpBeforeClass(): void
|
@@ -508,15 +518,7 @@ public function testDontRunAlternativeNamespaceName()
|
508 | 518 | $application->setAutoExit(false);
|
509 | 519 | $tester = new ApplicationTester($application);
|
510 | 520 | $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)); |
520 | 522 | }
|
521 | 523 |
|
522 | 524 | public function testCanRunAlternativeCommandName()
|
@@ -1956,15 +1958,38 @@ public function testSetSignalsToDisEvent()
|
1956 | 1958 | $diser = new EventDiser();
|
1957 | 1959 | $diser->addSubscriber($subscriber);
|
1958 | 1960 |
|
| 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 | + |
1959 | 1969 | $application = $this->createSignalableApplication($command, $diser);
|
1960 | 1970 | $application->setSignalsToDisEvent(\SIGUSR2);
|
1961 | 1971 | $this->assertSame(0, $application->run(new ArrayInput(['signal'])));
|
1962 | 1972 | $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, $diser); |
| 1979 | +$application->setSignalsToDisEvent(\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); |
1963 | 1987 |
|
1964 | 1988 | $application = $this->createSignalableApplication($command, $diser);
|
1965 | 1989 | $application->setSignalsToDisEvent(\SIGUSR1);
|
1966 | 1990 | $this->assertSame(1, $application->run(new ArrayInput(['signal'])));
|
1967 | 1991 | $this->assertTrue($subscriber->signaled);
|
| 1992 | +$this->assertFalse($blankHandlerSignaled); |
1968 | 1993 | }
|
1969 | 1994 |
|
1970 | 1995 | public function testSignalableCommandInterfaceWithoutSignals()
|
|
0 commit comments