$options, 'selected' => $selected); } class StubUser { private $home; function __construct($home) { $this->home = $home; } function HomeView() { return $this->home; } } function render($home) { global $block, $rendered; $User = new StubUser($home); $homeview_options = null; eval($block); htmlSelect('user[HomeView]', $homeview_options, $User->HomeView()); return $rendered; } $failures = 0; function check($name, $ok) { global $failures; if ($ok) { echo "ok - $name\n"; } else { $failures++; echo "FAIL - $name\n"; } } $r = render(''); check('no saved home view lists the seven views', count($r['options']) == 7 && isset($r['options'][''])); $r = render('montage'); check('a listed view is not added twice', count($r['options']) == 7 && $r['selected'] === 'montage'); $r = render('timeline'); check('a saved view outside the list is offered', isset($r['options']['timeline'])); check('and it is the selected one', $r['selected'] === 'timeline' && isset($r['options'][$r['selected']])); $r = render('watch&mid=3'); check('a saved view with parameters is offered', isset($r['options']['watch&mid=3']) && isset($r['options'][$r['selected']])); exit($failures ? 1 : 0);