noalyss Version-9
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
32include_once("../include/constant.php");
33include_once("lib/ac_common.php");
34require_once('class/database.class.php');
35require_once ('class/dossier.class.php');
36require_once('lib/html_input.class.php');
37require_once('lib/icon_action.class.php');
38require_once ('lib/function_javascript.php');
39require_once 'class/noalyss_user.class.php';
40require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
42global $http;
43
44$http=new HttpInput();
45
46
47$gDossier=$http->request('gDossier',"number", -1);
48if ($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}
56
58$g_user=new Noalyss_user($cn);
59
60if (!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}
66define('ALLOWED', 1);
68// To enable assert , set "zend.assertions" in the php.ini file
69ini_set("assert.active",1);
70assert_options(ASSERT_ACTIVE, 1);
71assert_options(ASSERT_WARNING, 1);
72//removed in PHP8 assert_options(ASSERT_QUIET_EVAL, 1);
74{
75 echo "<hr>Assert Failed :
76 File '$file'<br />
77 Line '$line'<br />
78 Code '$code'<br /><hr />";
79}
80assert_options(ASSERT_CALLBACK, 'my_assert_handler');
81/******************************************************************************************************************/
82/* Utilities
83/******************************************************************************************************************/
84
85/**
86 * Return the card this most activities
87 * @return integer (fiche.f_id)
88 */
90 global $cn;
91 $card_count=$cn->get_array("select count(*),f_id ".
92 " from jrnx ".
93 " where ".
94 " f_id is not null ".
95 "group by f_id order by count(*) desc");
96 return $card_count[0]['f_id'];
97}
98
99/*
100 * Loading of all scenario
101 */
102$scan=scandir('../scenario/');
105
106for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
107 {
108 if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true)
109 {
110 $description="";
111 $a_description=file('../scenario/'.$scan[$e_scan]);
112 $max_description=count($a_description);
113 for ($w=0; $w<$max_description; $w++)
114 {
115 if (strpos($a_description[$w], '@description:')==true)
116 {
117 $description=$a_description[$w];
118 $description=noalyss_str_replace('//@description:', '', $description);
119 }
120 }
121 $scenario[$cnt_scenario]['file']=$scan[$e_scan];
124
125
126 }
127 }
128$script=$http->request('script', "string",'');
129$min=$cn->get_value("select p_id from parm_periode order by p_start asc limit 1");
130$max=$cn->get_value("select p_id from parm_periode order by p_start desc limit 1");
131printf ("Max période %s Min période %s",$max,$min);
132
133if ($script=="")
134{
135 echo "<h1>Test NOALYSS</h1>";
136 /*
137 * cherche pour fichier a include, s'il y en a alors les affiche
138 * avec une description
139 */
140
141
142 echo '<table>';
143 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
144 echo '<tr>';
145 echo '<td>';
146 echo '<a href="'.$get.'" target="_blank">';
147 echo "Tous ";
148 echo '</a>';
149 echo '</td>';
150 echo '<td>Tous les scripts</td>';
151 echo '</tr>';
152
153 for ($e=0; $e<$cnt_scenario; $e++)
154 {
155
156 $get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc']));
157 echo '<tr>';
158 echo '<td>';
159 echo $e;
160 echo '</td>';
161 echo '<td>';
162 echo '<a href="'.$get.'" target="_blank">';
163 echo $scenario[$e]['file'];
164 echo '</a>';
165 echo '</td>';
166 echo '<td>'.$scenario[$e]['desc'].'</td>';
167 echo '</tr>';
168
169 }
170 echo '</table>';
171}
172else if ($script=='all')
173{
174 $nb=$http->get('nb_script', "number",0);
175
176 $start_mem=memory_get_usage();
177 $start_time=microtime(true);
179
180 echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
181 echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
182 include '../scenario/'.$scenario[$nb]['file'];
183 echo '</div>';
184 echo '</div>';
185 $end_mem=memory_get_usage();
186 $end_time=microtime(true);
187
188 echo "<p>start mem : ".$start_mem;
189 echo '</p>';
190 echo "<p>end mem : ".$end_mem;
191 echo '</p>';
192 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
193 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
194 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
195 echo '</p>';
196 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
197 $nb++;
198 if ( $nb == $maxscan ) {
199 echo "Dernier test";
200 } else {
201 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
202 echo '<a href="'.$get.'" target="_blank">';
203 echo $scenario[$nb]['file'];
204 }
205}
206else
207{
208 $start_mem=memory_get_usage();
209 $start_time=microtime(true);
211 $description=$http->get("description","string", "aucune description");
212 echo '<h1>'.$script."</h1>";
213 echo '<p> description = '.$description.'<p>';
214 include '../scenario/'.$script;
215
216 $end_mem=memory_get_usage();
217 $end_time=microtime(true);
218
219 echo "<p>start mem : ".$start_mem;
220 echo '</p>';
221 echo "<p>end mem : ".$end_mem;
222 echo '</p>';
223 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
224 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
225 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
226 echo '</p>';
227 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
228}
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
Definition: ac_common.php:275
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
$code
foreach($array as $idx=> $m) $w
static connect()
manage the http input (get , post, request) and extract from an array
Class to manage the company parameter (address, name...)
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
$end_mem
Definition: test.php:216
global $g_failed
Definition: test.php:54
$gDossier
Definition: test.php:47
global $cn
Definition: test.php:54
if($gDossier==-1) $gDossierLogInput
Definition: test.php:53
$scan
Definition: test.php:102
$maxscan
Definition: test.php:103
$end_time
Definition: test.php:217
$min
Definition: test.php:129
$start_time
Definition: test.php:209
global $http
Definition: test.php:42
$scenario
Definition: test.php:104
my_assert_handler($file, $line, $code)
Definition: test.php:73
$description
Definition: test.php:211
global $g_user
Definition: test.php:54
$g_parameter
Definition: test.php:57
$max
Definition: test.php:130
get_card_with_activity()
Return the card this most activities.
Definition: test.php:89
global $g_succeed
Definition: test.php:54
$cnt_scenario
Definition: test.php:104
for($e_scan=0; $e_scan< $maxscan; $e_scan++) $script
Definition: test.php:128