toBeFalse(); }); test('guard accepts a live process handle', function () { $process = proc_open('echo ok', [ 0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w'], ], $pipes); expect(rrd_process_started([$process, $pipes]))->toBeTrue(); foreach ($pipes as $pipe) { if (is_resource($pipe)) { fclose($pipe); } } proc_close($process); }); test('dereferencing the failure sentinel as pipes would crash without the guard', function () { $rrd_process = [false, false]; $pipes = $rrd_process[1]; // $pipes is false here; reaching fwrite($pipes[0], ...) is the poller crash. // The guard short-circuits before this point, which the boolean asserts. expect(rrd_process_started($rrd_process))->toBeFalse() ->and($pipes)->toBeFalse(); });