'Front', 'Type' => 'Remote', 'Restream' => '1'); $filled = monitorFillUncheckedFields($posted); check('unticked Exif becomes 0', $filled['Exif'], 0); check('ticked Restream is kept', $filled['Restream'], '1'); check('unticked Go2RTCEnabled becomes 0', $filled['Go2RTCEnabled'], 0); check('no trigger ticked becomes an empty list', $filled['Triggers'], array()); check('no group selected becomes an empty list', $filled['GroupIds'], array()); check('no linked monitors becomes an empty list', $filled['LinkedMonitors'], array()); check('a plain field is left alone', $filled['Name'], 'Front'); check('Method is not invented', isset($filled['Method']), false); check('V4LMultiBuffer is not invented', isset($filled['V4LMultiBuffer']), false); check('a field that was posted as empty string is kept', monitorFillUncheckedFields(array('Exif' => ''))['Exif'], ''); $hasControl = false; $noControl = monitorFillUncheckedFields(array('Name' => 'Front')); check('Controllable is not touched without Control permission', isset($noControl['Controllable']), false); check('TrackMotion is not touched without Control permission', isset($noControl['TrackMotion']), false); check('other checkboxes still default without Control permission', $noControl['Exif'], 0); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);