|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
global $store_config,$AR,$ariadne,$ax_config,$ARCurrent,$ARConfig,$ARLoader; |
|
4
|
|
|
$ariadne = getcwd().'/lib/'; |
|
5
|
|
|
$ARLoader = 'cmd'; |
|
6
|
|
|
|
|
7
|
|
|
require_once($ariadne.'/bootstrap.php'); |
|
8
|
|
|
require_once(AriadneBasePath .'/configs/axstore.phtml'); |
|
9
|
|
|
require_once(AriadneBasePath .'/stores/axstore.phtml'); |
|
10
|
|
|
|
|
11
|
|
|
function importContent($base, $package) { |
|
12
|
|
|
global $AR,$ARCurrent,$store_config,$ax_config; |
|
13
|
|
|
|
|
14
|
|
|
/* instantiate the store */ |
|
15
|
|
|
$storetype = $store_config["dbms"]."store"; |
|
16
|
|
|
$store = new $storetype($root,$store_config); |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
$ARCurrent->nolangcheck = true; |
|
19
|
|
|
|
|
20
|
|
|
// become admin |
|
21
|
|
|
$AR->user=new baseObject; |
|
22
|
|
|
$AR->user->data=new baseObject; |
|
|
|
|
|
|
23
|
|
|
$AR->user->data->login=$ARLogin="admin"; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
$ax_config["writeable"]=false; |
|
26
|
|
|
$ax_config["database"]=$package; |
|
27
|
|
|
set_time_limit(300); |
|
28
|
|
|
$storetype = $ax_config["dbms"]."store"; |
|
29
|
|
|
$axstore=new $storetype("", $ax_config); |
|
30
|
|
View Code Duplication |
if (!$axstore->error) { |
|
31
|
|
|
$ARCurrent->importStore=&$store; |
|
32
|
|
|
$args="srcpath=/&destpath=".$base; |
|
33
|
|
|
$axstore->call("system.export.phtml", $args, |
|
34
|
|
|
$axstore->get("/")); |
|
35
|
|
|
$error=$axstore->error; |
|
36
|
|
|
$axstore->close(); |
|
37
|
|
|
} else { |
|
38
|
|
|
$error=$axstore->error; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$store->close(); |
|
42
|
|
|
print $error; |
|
43
|
|
|
return $error; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function initTestData() { |
|
47
|
|
|
global $AR,$ARCurrent,$store_config,$store,$ARConfig; |
|
48
|
|
|
|
|
49
|
|
|
$origAR = clone $AR; |
|
50
|
|
|
$origARCurrent = clone $ARCurrent; |
|
51
|
|
|
$origARConfig = clone $ARConfig; |
|
52
|
|
|
|
|
53
|
|
|
// become admin |
|
54
|
|
|
$AR->user=new baseObject; |
|
55
|
|
|
$AR->user->data=new baseObject; |
|
|
|
|
|
|
56
|
|
|
$AR->user->data->login=$ARLogin="admin"; |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
/* instantiate the store */ |
|
59
|
|
|
$storetype = $store_config["dbms"]."store"; |
|
60
|
|
|
$store = new $storetype($root,$store_config); |
|
|
|
|
|
|
61
|
|
|
$res = ar::get('/projects/')->call('system.new.phtml', array ( |
|
62
|
|
|
'arNewType' => 'pproject', |
|
63
|
|
|
'arNewFilename' => '/projects/{5:id}', |
|
64
|
|
|
'en' => array ( |
|
65
|
|
|
'name' => 'Unit test dir (en)'.date(DATE_W3C) |
|
66
|
|
|
), |
|
67
|
|
|
'nl' => array ( |
|
68
|
|
|
'name' => 'Unit test dir (nl)'.date(DATE_W3C) |
|
69
|
|
|
), |
|
70
|
|
|
'de' => array ( |
|
71
|
|
|
'name' => 'Unit test dir (de)'.date(DATE_W3C) |
|
72
|
|
|
) |
|
73
|
|
|
) |
|
74
|
|
|
); |
|
75
|
|
|
$base = current($res); |
|
76
|
|
|
// set grants for testrunner user |
|
77
|
|
|
ar::get($res)->call('system.save.grants.phtml', array( |
|
78
|
|
|
"path" => '/system/users/testrunner/', |
|
79
|
|
|
"newgrants" => 'read add edit >delete config layout' |
|
80
|
|
|
)); |
|
81
|
|
|
define('TESTBASE',$base); |
|
82
|
|
|
|
|
83
|
|
|
importContent($base,getcwd().'/www/install/packages/demo.ax'); |
|
84
|
|
|
|
|
85
|
|
|
$AR = $origAR; |
|
86
|
|
|
$ARCurrent = $origARCurrent; |
|
87
|
|
|
$ARConfig = $origARConfig; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
abstract class AriadneBaseTest extends PHPUnit_Framework_TestCase |
|
91
|
|
|
{ |
|
92
|
|
|
protected function initAriadne() { |
|
93
|
|
|
global $ariadne,$store_config,$store,$AR; |
|
94
|
|
|
/* instantiate the store */ |
|
95
|
|
|
$inst_store = $store_config["dbms"]."store"; |
|
96
|
|
|
$store = new $inst_store($root,$store_config); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
/* now load a user (admin in this case)*/ |
|
99
|
|
|
$AR->user = new baseObject(); |
|
100
|
|
|
$AR->user->data = new baseObject(); |
|
|
|
|
|
|
101
|
|
|
$AR->user->data->login = "admin"; |
|
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
private static function loadTestData() { |
|
105
|
|
|
$name = get_called_class(); |
|
106
|
|
|
$reflector = new ReflectionClass($name); |
|
107
|
|
|
$file = $reflector->getFileName(); |
|
108
|
|
|
$file = preg_replace('/\.php$/','.ax',$file); |
|
109
|
|
|
if ( is_file($file) ) { |
|
110
|
|
|
importContent(TESTBASE, $file); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public static function setUpBeforeClass() { |
|
115
|
|
|
self::loadTestData(); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
initTestData(); |
|
122
|
|
|
|
|
123
|
|
|
// become testrunner |
|
124
|
|
|
$AR->user = current(ar::get('/system/users/testrunner/')->call('system.get.phtml')); |
|
125
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.