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
|
<?php
global $STUDIP_BASE_PATH, $ABSOLUTE_URI_STUDIP, $CACHING_ENABLE, $CACHING_FILECACHE_PATH, $SYMBOL_SHORT, $TMP_PATH, $UPLOAD_PATH, $ASSETS_URL;
// common set-up, usually done by lib/bootstraph.php and
// config/config_local.inc.php when run on web server
if (!isset($STUDIP_BASE_PATH)) {
$STUDIP_BASE_PATH = dirname(__DIR__, 2);
$ABSOLUTE_PATH_STUDIP = $STUDIP_BASE_PATH.'/public/';
$UPLOAD_PATH = $STUDIP_BASE_PATH.'/data/upload_doc';
$TMP_PATH = $TMP_PATH ?: '/tmp';
$ASSETS_URL = '';
}
// set include path
$inc_path = ini_get('include_path');
$inc_path .= PATH_SEPARATOR . __DIR__ . '/../..';
$inc_path .= PATH_SEPARATOR . __DIR__ . '/../../config';
ini_set('include_path', $inc_path);
require 'lib/helpers.php';
require 'lib/functions.php';
require_once 'lib/language.inc.php';
require 'lib/visual.inc.php';
require 'lib/messaging.inc.php';
$STUDIP_BASE_PATH = realpath(dirname(__FILE__) . '/../..');
// load config-variables
$added_configs = [];
StudipFileloader::load(
'config_defaults.inc.php config_local.inc.php',
$added_configs,
compact('STUDIP_BASE_PATH', 'ABSOLUTE_URI_STUDIP', 'ASSETS_URL'),
true
);
foreach($added_configs as $key => $value) {
$GLOBALS[$key] = $value;
}
require 'config/config.inc.php';
require_once __DIR__ . '/../../lib/bootstrap-autoload.php';
// Do not send mails of any kind during tests
require 'vendor/email_message/email_message.php';
require 'vendor/email_message/debug_message.php';
StudipMail::setDefaultTransporter(new debug_message_class());
$GLOBALS['template_factory'] = new Flexi\Factory(dirname(dirname(__DIR__)) . '/templates');
// Disable caching to fallback to memory cache
$GLOBALS['CACHING_ENABLE'] = false;
// SimpleORMapFake
if (!class_exists('StudipTestHelper')) {
class StudipTestHelper
{
static function set_up_tables($tables)
{
$cache = \Studip\Cache\Factory::getCache(false);
// second step, expire table scheme
SimpleORMap::expireTableScheme();
$schemes = [];
foreach ($tables as $db_table) {
include TEST_FIXTURES_PATH."simpleormap/$db_table.php";
$db_fields = $pk = [];
foreach ($result as $rs) {
$db_fields[mb_strtolower($rs['name'])] = [
'name' => $rs['name'],
'null' => $rs['null'],
'default' => $rs['default'],
'type' => $rs['type'],
'extra' => $rs['extra']
];
if ($rs['key'] == 'PRI'){
$pk[] = mb_strtolower($rs['name']);
}
}
$schemes[$db_table]['db_fields'] = $db_fields;
$schemes[$db_table]['pk'] = $pk;
}
$cache->write('DB_TABLE_SCHEMES', serialize($schemes));
}
static function tear_down_tables()
{
SimpleORMap::expireTableScheme();
}
}
}
|