Blame view

test/test.php 2.69 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
<?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");

8c57155b   Benjamin Renard   Integration for t...
13
14
15
define('BASE_PATH', IHM_SRC_DIR);
define('DATAPATH', BASE_PATH.'generic_data/');

22521f1c   Benjamin Renard   First commit
16
//define test suite
8c57155b   Benjamin Renard   Integration for t...
17
/*require_once(__DIR__."/US42/test_us42.php");
22521f1c   Benjamin Renard   First commit
18
19
20
require_once(__DIR__."/US44/test_us44.php");
require_once(__DIR__."/US43/test_us43.php");
require_once(__DIR__."/US78/test_us78.php");
8c57155b   Benjamin Renard   Integration for t...
21
22
require_once(__DIR__."/LocalParam/test_localparam.php");*/
require_once(__DIR__."/debug_request.php");
22521f1c   Benjamin Renard   First commit
23

8c57155b   Benjamin Renard   Integration for t...
24
$testSuite = array($debug)/*$us42,$us44,$us43,$us78,$localparam)*/;
22521f1c   Benjamin Renard   First commit
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

//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
944199fe   Benjamin Renard   Use table definit...
40
41
42
43
44
45
46
47
48
49
50
51
copy(__DIR__."/../install/testParams/UserParams/WsParams.xml","WsParams.xml");
copy(__DIR__."/../install/testParams/UserParams/ws_0.xml","ws_0.xml");
copy(__DIR__."/../install/testParams/UserParams/wsd_0.xml","wsd_0.xml");
copy(__DIR__."/../install/testParams/UserParams/wsd_1.xml","wsd_1.xml");
//copy some uploaded files for test
chdir(IHM_SRC_DIR."data");
chdir(NEWKERNEL_DEBUG_USER);
if (!is_dir("DATA"))
	mkdir("DATA");
chdir("DATA");
copy(__DIR__."/../install/testParams/UserData/base.xml","base.xml");
copy(__DIR__."/../install/testParams/UserData/2007001.skr-v3.xml","2007001.skr-v3.xml");
22521f1c   Benjamin Renard   First commit
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

//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;
		}
	}

?>