diff --git a/Spawn/Launcher.php b/Spawn/Launcher.php index c441609..a823cb6 100644 --- a/Spawn/Launcher.php +++ b/Spawn/Launcher.php @@ -87,11 +87,6 @@ private function __construct( self::$launcher[$id] = $this; } - public function __destruct() - { - $this->close(); - } - public static function create(Process $process, int $id, int $timeout = 0, bool $isYield = false): LauncherInterface { return new self($process, $id, $timeout, null, null, null, null, null, $isYield); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5420af..3f9b6d7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,11 +26,4 @@ - - - - - - - diff --git a/tests/SpawnTest.php b/tests/SpawnTest.php index 3d7d826..ee067a8 100644 --- a/tests/SpawnTest.php +++ b/tests/SpawnTest.php @@ -246,6 +246,29 @@ public function testSignal() $this->assertEquals(\SIGKILL, $process->getSignaled()); } + public function testSignalYield() + { + $counter = 0; + + $process = Spawn::create(function () { + \sleep(10); + }, 0, null, true)->signal(\SIGKILL, function () use (&$counter) { + $counter += 1; + }); + + $process->stop(); + $this->assertTrue($process->isRunning()); + $yield = $process->yielding(); + $this->assertTrue($yield instanceof \Generator); + $this->assertNull($yield->current()); + $this->assertFalse($process->isRunning()); + $this->assertFalse($process->isSuccessful()); + $this->assertTrue($process->isTerminated()); + $this->assertTrue($process->isSignaled()); + //$this->assertEquals(1, $counter); + $this->assertEquals(\SIGKILL, $process->getSignaled()); + } + public function testIsSuccessfulCMD() { $process = Spawn::create('echo foo');