public function testProcOpenFail() { $this->skipIfNotUnix(); $this->setExpectedException('ptlis\\ShellCommand\\Exceptions\\CommandExecutionException', 'Call to proc_terminate with signal "' . ProcessInterface::SIGTERM . '" failed for unknown reason.'); $command = './tests/commands/unix/test_binary'; $process = new Process(new UnixEnvironment(), $command, getcwd()); $process->stop(); }
public function testSendSignal() { $this->skipIfNotUnix(); $command = './tests/commands/unix/sleep_binary'; $mockLogger = new MockPsrLogger(); $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new ErrorLogger($mockLogger)); $process->stop(); $this->assertLogsMatch(array(array('level' => LogLevel::ERROR, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $mockLogger->getLogs()); }
public function testStopRunning() { $this->skipIfNotUnix(); $command = './tests/commands/unix/sleep_binary'; $logger = new MockPsrLogger(); $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AllLogger($logger)); $process->stop(); $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/sleep_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Signal sent', 'context' => array('signal' => ProcessInterface::SIGTERM)), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $logger->getLogs()); }