test.php
2.04 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
<?php
error_reporting(E_ALL & ~E_NOTICE);
//Path to AMDA_Integration base dir
define('INTEGRATION_BASE_PATH', __DIR__.'/../');
require(__DIR__.'/../config/AMDAIntegrationConfig.php');
//Used to skip checkUser in AMDAAction.php
define("NEWKERNEL_DEBUG",true);
define("NEWKERNEL_DEBUG_USER","test-integration");
//define test suite
require_once(__DIR__."/US42/test_us42.php");
require_once(__DIR__."/US44/test_us44.php");
require_once(__DIR__."/US43/test_us43.php");
require_once(__DIR__."/US78/test_us78.php");
$testSuite = array($us42,$us44,$us43,$us78);
//include required IHM source
require_once(IHM_SRC_DIR."php/classes/AmdaAction.php");
require_once(IHM_SRC_DIR."php/classes/UserMgr.php");
require_once(IHM_SRC_DIR."php/classes/AmdaClient.php");
//create test WS
chdir(IHM_SRC_DIR."data");
if (!is_dir(NEWKERNEL_DEBUG_USER))
mkdir(NEWKERNEL_DEBUG_USER);
chdir(NEWKERNEL_DEBUG_USER);
if (!is_dir("WS"))
mkdir("WS");
chdir("WS");
//copy some user parameters for test
copy(__DIR__."/../install/testParams/DerivedParams/WsParams.xml","WsParams.xml");
copy(__DIR__."/../install/testParams/DerivedParams/ws_0.xml","ws_0.xml");
//assure DDServer connection
chdir(NEWKERNEL_BASE_PATH."app-debug/");
exec(NEWKERNEL_BASE_PATH."script/loginDD_Server.sh");
chdir(__DIR__);
//create an instance of AmdaAction
$amdaAction = new AmdaAction();
//run test suite
foreach ($testSuite as $us)
foreach ($us as $key=>$value)
{
echo '-------------------------------------------------------'.PHP_EOL;
echo $key.PHP_EOL;
try {
$obj = json_decode($value);
$nodeType = "";
if (isset($obj->nodeType))
$nodeType = $obj->nodeType;
$result = $amdaAction->execute($obj->nodeType, $obj);
if ($result['success'])
{
if ($result['status'] == 'error')
{
echo 'Error during execution !'.PHP_EOL;
}
else
echo 'Success !'.PHP_EOL;
}
else
echo 'Error ! '.$result['message'].PHP_EOL;
} catch (Exception $e) {
echo 'Exception detected : '.$e->getMessage().PHP_EOL;
}
}
?>