public function testCalled() { $this->skipIfNotUnix(); $command = './tests/commands/unix/test_binary'; $mockLogger = new MockPsrLogger(); $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AllLogger($mockLogger)); $process->wait(); $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/test_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Read from stdout', 'context' => array('stdout' => 'Test command' . PHP_EOL . PHP_EOL)), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => 0))), $mockLogger->getLogs()); }
public function testCalledWithCustomLogLevel() { $this->skipIfNotUnix(); $command = './tests/commands/unix/error_binary'; $mockLogger = new MockPsrLogger(); $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new ErrorLogger($mockLogger, LogLevel::CRITICAL)); $process->wait(); $this->assertLogsMatch(array(array('level' => LogLevel::CRITICAL, 'message' => 'Read from stderr', 'context' => array('stderr' => 'Fatal Error' . PHP_EOL)), array('level' => LogLevel::CRITICAL, 'message' => 'Process exited', 'context' => array('exit_code' => 5))), $mockLogger->getLogs()); }
public function testErrorGetPidNotRunning() { $this->skipIfNotWindows(); $this->setExpectedException('RuntimeException', 'Cannot get the process id of a process that has already exited.'); $command = 'tests\\commands\\windows\\test.bat'; $process = new Process(new WindowsEnvironment(), $command, getcwd()); $process->wait(); $process->getPid(); }
public function testAggregateLogger() { $this->skipIfNotUnix(); $command = './tests/commands/unix/long_sleep_binary'; $mockLogger = new MockPsrLogger(); $allLogger = new AllLogger($mockLogger); $process = new Process(new UnixEnvironment(), $command, getcwd(), -1, 1000, new AggregateLogger(array($allLogger, new NullProcessObserver()))); $process->sendSignal(Process::SIGTERM); $process->wait(); $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/long_sleep_binary')), array('level' => LogLevel::DEBUG, 'message' => 'Signal sent', 'context' => array('signal' => 'SIGTERM')), array('level' => LogLevel::DEBUG, 'message' => 'Process exited', 'context' => array('exit_code' => -1))), $mockLogger->getLogs()); }
public function testTimeoutLongRunning() { $this->skipIfNotUnix(); $command = './tests/commands/unix/long_sleep_binary'; $logger = new MockPsrLogger(); $process = new Process(new UnixEnvironment(), $command, getcwd(), 500000, 1000, new AllLogger($logger)); $process->wait(); $this->assertLogsMatch(array(array('level' => LogLevel::DEBUG, 'message' => 'Process created', 'context' => array('command' => './tests/commands/unix/long_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()); }