noalyss  Version-7
test.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21 /*!\file
22  * \brief this file let you debug and test the different functionnalities, there are 2 important things to do
23  * It is only a quick and dirty testing. You should use a tool as PHPUNIT for the unit testing
24  *
25  * - first do not forget to create the authorized_debug file in the html folder
26  * - secund the test must be adapted to this page : if you do a post (or get) from a test, you won't get any result
27  * if the $_REQUEST[test_select] is not set, so set it .
28  */
29 
30 
31 
32 include_once("../include/constant.php");
33 include_once("lib/ac_common.php");
34 require_once('lib/database.class.php');
35 require_once ('class/dossier.class.php');
36 require_once('lib/html_input.class.php');
37 require_once('lib/icon_action.class.php');
38 require_once ('lib/function_javascript.php');
39 require_once 'class/user.class.php';
40 require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
41 
42 global $http;
43 
44 $http=new HttpInput();
45 
48 if ($gDossier==-1)
49 {
50  echo " Vous devez donner le dossier avec param├Ętre gDossier dans l'url, exemple http://localhost/noalyss/html/test.php?gDossier=25";
51  exit();
52 }
55 $cn=Dossier::connect();
56 
58 $g_user=new User($cn);
59 
60 if (!file_exists('authorized_debug'))
61 {
62  echo "Pour pouvoir utiliser ce fichier vous devez creer un fichier nomme authorized_debug
63  dans le repertoire html du server";
64  exit();
65 }
66 define('ALLOWED', 1);
67 html_page_start("Classic 692");
68 
69 /*
70  * Loading of all scenario
71  */
72 $scan=scandir('../scenario/');
73 $maxscan=count($scan);
75 
76 for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
77  {
78  if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true)
79  {
80  $description="";
81  $a_description=file('../scenario/'.$scan[$e_scan]);
82  $max_description=count($a_description);
83  for ($w=0; $w<$max_description; $w++)
84  {
85  if (strpos($a_description[$w], '@description:')==true)
86  {
87  $description=$a_description[$w];
88  $description=str_replace('//@description:', '', $description);
89  }
90  }
91  $scenario[$cnt_scenario]['file']=$scan[$e_scan];
93  $cnt_scenario++;
94 
95 
96  }
97  }
99 if ($script=="")
100 {
101  echo "<h1>Test NOALYSS</h1>";
102  /*
103  * cherche pour fichier a include, s'il y en a alors les affiche
104  * avec une description
105  */
106 
107 
108  echo '<table>';
109  $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
110  echo '<tr>';
111  echo '<td>';
112  echo '<a href="'.$get.'" target="_blank">';
113  echo "Tous ";
114  echo '</a>';
115  echo '</td>';
116  echo '<td>Tous les scripts</td>';
117  echo '</tr>';
118 
119  for ($e=0; $e<$cnt_scenario; $e++)
120  {
121 
122  $get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc']));
123  echo '<tr>';
124  echo '<td>';
125  echo $e;
126  echo '</td>';
127  echo '<td>';
128  echo '<a href="'.$get.'" target="_blank">';
129  echo $scenario[$e]['file'];
130  echo '</a>';
131  echo '</td>';
132  echo '<td>'.$scenario[$e]['desc'].'</td>';
133  echo '</tr>';
134 
135  }
136  echo '</table>';
137 }
138 else if ($script=='all')
139 {
140  $nb=HtmlInput::default_value_get('nb_script', 0);
141 
142  $start_mem=memory_get_usage();
143  $start_time=microtime(true);
144  $script=str_replace('../', '', $script);
145 
146  echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
147  echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
148  include '../scenario/'.$scenario[$nb]['file'];
149  echo '</div>';
150  echo '</div>';
151  $end_mem=memory_get_usage();
152  $end_time=microtime(true);
153 
154  echo "<p>start mem : ".$start_mem;
155  echo '</p>';
156  echo "<p>end mem : ".$end_mem;
157  echo '</p>';
158  echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
159  echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
160  echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
161  echo '</p>';
162  echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
163  $nb++;
164  if ( $nb == $maxscan ) {
165  echo "Dernier test";
166  } else {
167  $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
168  echo '<a href="'.$get.'" target="_blank">';
169  echo $scenario[$nb]['file'];
170  }
171 }
172 else
173 {
174  $start_mem=memory_get_usage();
175  $start_time=microtime(true);
176  $script=str_replace('../', '', $script);
177  $description=HtmlInput::default_value_get("description", "aucune description");
178  echo '<h1>'.$script."</h1>";
179  echo '<p> description = '.$description.'<p>';
180  include '../scenario/'.$script;
181 
182  $end_mem=memory_get_usage();
183  $end_time=microtime(true);
184 
185  echo "<p>start mem : ".$start_mem;
186  echo '</p>';
187  echo "<p>end mem : ".$end_mem;
188  echo '</p>';
189  echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
190  echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
191  echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
192  echo '</p>';
193  echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
194 }
global $g_succeed
Definition: test.php:54
if($gDossier==-1) $gDossierLogInput
Definition: test.php:53
$end_mem
Definition: test.php:182
for($e_scan=0;$e_scan<$maxscan;$e_scan++) $script
Definition: test.php:98
$cnt_scenario
Definition: test.php:74
Data & function about connected users.
Definition: user.class.php:36
$end_time
Definition: test.php:183
foreach($array as $idx=> $m) $w
$scenario
Definition: test.php:74
$scan
Definition: test.php:72
$maxscan
Definition: test.php:73
Class to manage the company parameter (address, name...)
load_all_script()
load all the javascript only one time
$g_parameter
Definition: test.php:57
global $g_failed
Definition: test.php:54
$description
Definition: test.php:177
static default_value_get($ind, $default)
return default if the value if the value doesn&#39;t exist in $_GET use HttpInput instead ...
static connect()
$start_time
Definition: test.php:175
global $http
Definition: test.php:32
$gDossier
Definition: test.php:47
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
Definition: ac_common.php:262
global $cn
Definition: test.php:54
for($e=0;$e< count($afiche);$e++) exit
global $g_user
Definition: test.php:54