'A1', 'AlarmInput' => 'B1', 'AlarmOutput' => 'C1'); try { eval($block); } catch (Throwable $e) { return 'threw: '.$e->getMessage(); } return $newX10Monitor; } $stored = array('Activation' => 'A1', 'AlarmInput' => 'B1', 'AlarmOutput' => 'C1'); check('a link with newMonitor and no newX10Monitor uses the stored X10 values', run(array('newMonitor' => array('Path' => 'rtsp://cam')), 'GET'), $stored); check('a posted newX10Monitor is used', run(array('newMonitor' => array('Name' => 'x'), 'newX10Monitor' => array('Activation' => 'A2', 'AlarmInput' => 'B2', 'AlarmOutput' => 'C2')), 'POST'), array('Activation' => 'A2', 'AlarmInput' => 'B2', 'AlarmOutput' => 'C2')); check('a posted newX10Monitor missing a key falls back to the stored value for it', run(array('newMonitor' => array('Name' => 'x'), 'newX10Monitor' => array('Activation' => 'A2')), 'POST'), array('Activation' => 'A2', 'AlarmInput' => 'B1', 'AlarmOutput' => 'C1')); check('a newX10Monitor that is not an array is ignored', run(array('newMonitor' => array('Name' => 'x'), 'newX10Monitor' => 'junk'), 'POST'), $stored); check('no newMonitor uses the stored X10 values', run(array(), 'GET'), $stored); exit($failures ? 1 : 0);