Id = 3; } public function Server() { return new ServerStub(); } public function ViewWidth() { return 640; } public function ViewHeight() { return 480; } '.method_source($root.'/includes/Monitor.php', 'getStreamSrc').' }'); eval('#[AllowDynamicProperties] class EventStub { public function __construct() { $this->Id = 7; $this->MonitorId = 3; $this->DefaultVideo = ""; } public function Server() { return new ServerStub(); } public function Path() { return "/nonexistent"; } public function ThumbnailWidth() { return 160; } public function ThumbnailHeight() { return 120; } '.method_source($root.'/includes/Event.php', 'getStreamSrc').' '.method_source($root.'/includes/Event.php', 'getThumbnailSrc').' }'); $builders = array( 'Monitor::getStreamSrc' => function() { return (new MonitorStub())->getStreamSrc(array('mode' => 'jpeg', 'scale' => 100), '&'); }, 'Event::getStreamSrc' => function() { return (new EventStub())->getStreamSrc(array('mode' => 'jpeg'), '&'); }, 'Event::getThumbnailSrc' => function() { return (new EventStub())->getThumbnailSrc(array(), '&'); }, ); foreach ($builders as $name => $build) { $_SESSION = array(); $warnings = array(); $url = $build(); check("$name: no warning without a session username", !$warnings); if ($warnings) echo ' '.implode("\n ", $warnings)."\n"; check("$name: URL is still built", strpos($url, 'monitor=') !== false || strpos($url, 'eid=') !== false || strpos($url, 'event=') !== false); $_SESSION = array('username' => 'alice'); $warnings = array(); $url = $build(); check("$name: user=alice with a session username", strpos($url, 'user=alice') !== false && !$warnings); } exit($failures ? 1 : 0);