type = $type; $this->fps = $fps; $this->capturing = $capturing; } function Type() { return $this->type; } function CaptureFPS() { return $this->fps; } function Capturing() { return $this->capturing; } } $canViewStream = true; function canView($what) { global $canViewStream; return $canViewStream; } $failures = 0; function check($name, $monitor, $canView, $want) { global $line, $failures, $canViewStream; $canViewStream = $canView; $stream_available = null; eval($line); if ((bool)$stream_available === $want) { echo "ok - $name\n"; } else { $failures++; echo "FAIL - $name (got ".var_export((bool)$stream_available, true).")\n"; } } check('capturing monitor links to watch', new StubMonitor('Ffmpeg', '10.00', 'Always'), true, true); check('web site monitor links to watch', new StubMonitor('WebSite', null, 'Always'), true, true); check('monitor with no capture fps has no watch link', new StubMonitor('Ffmpeg', null, 'Always'), true, false); check('monitor with Capturing None has no watch link', new StubMonitor('Ffmpeg', '10.00', 'None'), true, false); check('user without Stream view gets no link for a capturing monitor', new StubMonitor('Ffmpeg', '10.00', 'Always'), false, false); check('user without Stream view gets no link for a web site', new StubMonitor('WebSite', null, 'Always'), false, false); exit($failures ? 1 : 0);