File: 1.00.0a/server/base/nats.tests.inc.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: class TNATS_Test 24: { 25: var $type=""; 26: var $instance=false; 27: var $class=""; 28: var $name=""; 29: var $revision=-1; 30: var $additional=""; 31: var $parameters=false; 32: 33: function TNATS_Test($type,$class,$parameters=false,$name="",$revision=0,$additional="") 34: { 35: $this->type=$type; 36: $this->class=$class; 37: if ($name=="") $this->name=$type; 38: else $this->name=$name; 39: $this->revision=$revision; 40: $this->additional=$additional; 41: if ($parameters===false) $this->parameters=array(); 42: else $this->parameters=$parameters; 43: } 44: 45: function Create() 46: { 47: if ($this->instance===false) // doesn't exist 48: { 49: $this->instance=new $this->class(); 50: } 51: return $this->instance; 52: } 53: } 54: 55: class TNATS_Tests 56: { 57: var $count=0; 58: var $Tests=array(); 59: var $QuickList=array(); // quick list to save doing it dynamically each time 60: 61: function Register($type,$class,$parameters=false,$name="",$revision=0,$additional="") 62: { 63: if ($name=="") $name=$type; 64: $this->Tests[$type]=new TNATS_Test($type,$class,$parameters,$name,$revision,$additional); 65: $this->QuickList[$type]=$name; 66: $this->count++; 67: } 68: 69: function Get($type) 70: { 71: if (isset($this->Tests[$type])) return $this->Tests[$type]; 72: return -1; 73: } 74: 75: function QuickList() 76: { 77: return $this->QuickList; 78: } 79: 80: } 81: ?>