This repository was archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
106 lines (90 loc) · 2.01 KB
/
test.php
File metadata and controls
106 lines (90 loc) · 2.01 KB
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
<?
/*
* Swim
*
* SWIM unit tests
*
* Copyright Blueprint IT Ltd. 2007
*
* $HeadURL$
* $LastChangedBy$
* $Date$
* $Revision$
*/
function logTest($id,$desc,$comparison)
{
global $log;
if ($comparison)
{
$log->debug('Passed test '.$id.': '.$desc);
}
else
{
$log->error('Failed test '.$id.': '.$desc);
}
}
function run_test($file)
{
global $_PREFS,$log;
include($_PREFS->getPref('storage.test').'/'.$file);
}
function run_all_tests()
{
global $_PREFS,$log;
$testdir=opendir($_PREFS->getPref('storage.test'));
while (($testfile = readdir($testdir)) !== false)
{
if (substr($testfile,-4)=='.php')
{
$type=substr($testfile,0,-4);
$log = LoggerManager::getLogger('test.'.$type);
$log->info('Running tests from '.$testfile);
run_test($testfile);
}
}
}
$source = $_SERVER["SCRIPT_FILENAME"];
$sitebase = dirname($source);
if (is_dir($sitebase.'/swim/bootstrap'))
{
$swimbase = $sitebase.'/swim';
}
else
{
while (is_link($source))
{
$source=readlink($source);
}
$swimbase = dirname($source);
}
unset($source);
require_once $swimbase.'/bootstrap/bootstrap.php';
unset($swimbase);
unset($sitebase);
SwimEngine::startup();
AddonManager::disable();
SwimEngine::ensureStarted();
LoggerManager::setLogOutput("",new PageLogOutput());
LoggerManager::setLogLevel('test',LOG_LEVEL_INFO);
if (isset($_GET['level']))
{
$lev = strtolower($_GET['level']);
if ($lev=='debug')
LoggerManager::setLogLevel('test',LOG_LEVEL_DEBUG);
else if ($lev=='info')
LoggerManager::setLogLevel('test',LOG_LEVEL_INFO);
else if ($lev=='warn')
LoggerManager::setLogLevel('test',LOG_LEVEL_WARN);
else if ($lev=='error')
LoggerManager::setLogLevel('test',LOG_LEVEL_ERROR);
else if ($lev=='fatal')
LoggerManager::setLogLevel('test',LOG_LEVEL_FATAL);
}
$log=LoggerManager::getLogger('test');
$log->info('Test start');
$_STATE=STATE_PROCESSING;
run_all_tests();
$log=LoggerManager::getLogger('test');
$log->info('Test end');
//SwimEngine::shutdown();
?>