-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathfunctions.php
More file actions
99 lines (90 loc) · 2.24 KB
/
functions.php
File metadata and controls
99 lines (90 loc) · 2.24 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
<?php
/**
* Part of ci-phpunit-test
*
* @author Kenji Suzuki <https://github.com/kenjis>
* @license MIT License
* @copyright 2015 Kenji Suzuki
* @link https://github.com/kenjis/ci-phpunit-test
*/
/**
* Inject instance to load_class() function
*
* @param string $classname
* @param object $instance
*/
function load_class_instance($classname, $instance)
{
load_class($classname, '', NULL, FALSE, $instance);
}
/**
* Reset CodeIgniter instance
*/
function reset_instance()
{
// Reset loaded classes
load_class('', '', NULL, TRUE);
is_loaded('', TRUE);
// Reset config functions
reset_config();
// Close db connection
$CI =& get_instance();
if (isset($CI->db))
{
if (
$CI->db->dsn !== 'sqlite::memory:'
&& $CI->db->database !== ':memory:'
)
{
$CI->db->close();
$CI->db = null;
}
else
{
// Don't close if SQLite in-memory database
// If we close it, all tables and stored data will be gone
load_class_instance('db', $CI->db);
}
}
// Load core classes
$BM =& load_class('Benchmark', 'core');
CIPHPUnitTestSuperGlobal::set_Global('BM', $BM);
$EXT =& load_class('Hooks', 'core');
CIPHPUnitTestSuperGlobal::set_Global('EXT', $EXT);
$CFG =& load_class('Config', 'core');
CIPHPUnitTestSuperGlobal::set_Global('CFG', $CFG);
$UNI =& load_class('URI', 'core', $CFG);
CIPHPUnitTestSuperGlobal::set_Global('UNI', $UNI);
// $URI =& load_class('Utf8', 'core');
// CIPHPUnitTestSuperGlobal::set_Global('URI', $URI);
$RTR =& load_class('Router', 'core');
CIPHPUnitTestSuperGlobal::set_Global('RTR', $RTR);
$OUT =& load_class('Output', 'core');
CIPHPUnitTestSuperGlobal::set_Global('OUT', $OUT);
$SEC =& load_class('Security', 'core');
CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC);
$IN =& load_class('Input', 'core');
CIPHPUnitTestSuperGlobal::set_Global('IN', $IN);
$LANG =& load_class('Lang', 'core');
CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG);
CIPHPUnitTest::loadLoader();
// Remove CodeIgniter instance
$CI = new CIPHPUnitTestNullCodeIgniter();
}
/**
* Set return value of is_cli() function
*
* @param bool $return
*/
function set_is_cli($return)
{
is_cli($return);
}
/**
* Reset config functions
*/
function reset_config()
{
get_config([], TRUE);
config_item(NULL, TRUE);
}