/** * was the command successful, according to its return code? * * this isn't 100% reliable, as there are plenty of CLI commands out * there which no longer respect the UNIX convention on return codes * * @param ProcessResult $commandResult * the result to check * @return boolean * TRUE if the command was successful * FALSE otherwise */ public static function checkProcessResult(ProcessResult $commandResult) { if ($commandResult->getReturnCode() === 0) { return true; } return false; }
public function __construct(ProcessResult $result) { $msg = "Command '" . $result->getCommandAsString() . ' succeeded with return code ' . $result->getReturnCode(); parent::__construct(400, $msg, ['result' => $result]); }
/** * @covers ::__construct */ public function testCanGetResultCode() { // ---------------------------------------------------------------- // setup your test $expectedResult = 100; $obj = new ProcessResult([], $expectedResult, ''); // ---------------------------------------------------------------- // perform the change $actualResult = $obj->getReturnCode(); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }