forked from ddurieux/glpi_monitoring
/
AllTests.php
142 lines (116 loc) · 5 KB
/
AllTests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/*
------------------------------------------------------------------------
Plugin Monitoring for GLPI
Copyright (C) 2011-2012 by the Plugin Monitoring for GLPI Development Team.
https://forge.indepnet.net/projects/monitoring/
------------------------------------------------------------------------
LICENSE
This file is part of Plugin Monitoring project.
Plugin Monitoring for GLPI is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plugin Monitoring for GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Behaviors. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package Plugin Monitoring for GLPI
@author David Durieux
@co-author
@comment
@copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://forge.indepnet.net/projects/monitoring/
@since 2011
------------------------------------------------------------------------
*/
if (!defined('GLPI_ROOT')) {
define('GLPI_ROOT', '../../..');
file_put_contents(GLPI_ROOT."/files/_log/sql-errors.log", '');
file_put_contents(GLPI_ROOT."/files/_log/php-errors.log", '');
include_once (GLPI_ROOT . "/inc/timer.class.php");
include_once (GLPI_ROOT . "/inc/common.function.php");
// Security of PHP_SELF
$_SERVER['PHP_SELF']=cleanParametersURL($_SERVER['PHP_SELF']);
function glpiautoload($classname) {
global $DEBUG_AUTOLOAD, $CFG_GLPI;
static $notfound = array();
// empty classname or non concerted plugin
if (empty($classname) || is_numeric($classname)) {
return false;
}
$dir=GLPI_ROOT . "/inc/";
//$classname="PluginExampleProfile";
if ($plug=isPluginItemType($classname)) {
$plugname=strtolower($plug['plugin']);
$dir=GLPI_ROOT . "/plugins/$plugname/inc/";
$item=strtolower($plug['class']);
// Is the plugin activate ?
// Command line usage of GLPI : need to do a real check plugin activation
if (isCommandLine()) {
$plugin = new Plugin();
if (count($plugin->find("directory='$plugname' AND state=".Plugin::ACTIVATED)) == 0) {
// Plugin does not exists or not activated
return false;
}
} else {
// Standard use of GLPI
if (!in_array($plugname,$_SESSION['glpi_plugins'])) {
// Plugin not activated
return false;
}
}
} else {
// Is ezComponent class ?
if (preg_match('/^ezc([A-Z][a-z]+)/',$classname,$matches)) {
include_once(GLPI_EZC_BASE);
ezcBase::autoload($classname);
return true;
} else {
$item=strtolower($classname);
}
}
// No errors for missing classes due to implementation
if (!isset($CFG_GLPI['missingclasses'])
OR !in_array($item,$CFG_GLPI['missingclasses'])){
if (file_exists("$dir$item.class.php")) {
include_once ("$dir$item.class.php");
if ($_SESSION['glpi_use_mode']==DEBUG_MODE) {
$DEBUG_AUTOLOAD[]=$classname;
}
} else if (!isset($notfound["x$classname"])) {
// trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case)
//logInFile('debug',"file $dir$item.class.php not founded trying to load class $classname\n");
trigger_error("GLPI autoload : file $dir$item.class.php not founded trying to load class '$classname'");
$notfound["x$classname"] = true;
}
}
}
spl_autoload_register('glpiautoload');
include (GLPI_ROOT . "/config/based_config.php");
include (GLPI_ROOT . "/inc/includes.php");
restore_error_handler();
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors','On');
}
ini_set("memory_limit", "-1");
ini_set("max_execution_time", "0");
require_once 'GLPIInstall/AllTests.php';
require_once 'MonitoringInstall/AllTests.php';
require_once 'GLPIlogs/AllTests.php';
require_once 'ManageRessources/AllTests.php';
class AllTests {
public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('Monitoring');
$suite->addTest(GLPIInstall_AllTests::suite());
$suite->addTest(MonitoringInstall_AllTests::suite());
$suite->addTest(ManageRessources_AllTests::suite());
return $suite;
}
}
?>