$v) $this->{$k} = $v; } public function Id() { return $this->{'Id'} ?? null; } public function Name() { return $this->{'Name'} ?? null; } public function ParentId() { return $this->{'ParentId'} ?? null; } public static function _find($class, $params = null, $options = null) { global $T_groups, $T_monitors; $rows = ($class === Group::class) ? $T_groups : $T_monitors; $out = array(); foreach ($rows as $row) { $ok = true; foreach ((array)$params as $f => $v) { if (is_array($v)) { if (!in_array($row[$f], $v)) $ok = false; } else if ($v === null) { if ($row[$f] !== null) $ok = false; } else if ($row[$f] != $v) $ok = false; } if ($ok) $out[] = new $class($row); } return $out; } public static function _find_one($class, $params = array(), $options = array()) { $r = self::_find($class, $params, $options); return $r ? $r[0] : null; } } class Monitor extends ZM_Object { public static function find($p = array(), $o = array()) { return ZM_Object::_find(self::class, $p, $o); } public function canView($u = null) { return true; } } class Group_Permission extends ZM_Object {} } namespace { $T_groups = array( array('Id'=>1, 'Name'=>'Parent', 'ParentId'=>null), array('Id'=>2, 'Name'=>'Child', 'ParentId'=>1), ); $T_monitors = array( array('Id'=>10, 'Name'=>'A', 'Deleted'=>0), array('Id'=>11, 'Name'=>'B', 'Deleted'=>0), ); $T_gm = array(1=>array(10), 2=>array(11)); function dbFetchAll($sql, $col = null, $params = array()) { global $T_gm; if (strpos($sql, 'Groups_Monitors') !== false) return $T_gm[$params[0]] ?? array(); return array(); } function dbQuery() {} function Warning() {} function Error() {} $tests = 0; $failures = 0; function check($label, $cond) { global $tests, $failures; $tests++; if ($cond) echo " ok - $label\n"; else { $failures++; echo " NOT OK - $label\n"; } } $src = file_get_contents(dirname(__DIR__, 2).'/web/includes/Group.php'); eval('?>'.preg_replace('/^<\?php\s*namespace ZM;/', '