noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
33
34include_once("../include/constant.php");
35include_once("lib/ac_common.php");
36
37
38
40global $http;
41define ('TEST_UNIT',1);
42$http=new HttpInput();
43
44if ( ini_get('zend.assertions') != 1 ) {
45 echo_warning(_('Attention zend.assertions devrait être activé'));
46 echo p('Il faut changer dans votre fichier .htaccess ou php.ini');
47 echo 'voir <a href="https://www.php.net/manual/fr/ini.core.php#ini.zend.assertions">https://www.php.net/manual/fr/ini.core.php#ini.zend.assertions</a>';
48}
49$gDossier=$http->request('gDossier',"number", -1);
50if ($gDossier==-1)
51{
52 echo " Vous devez donner le dossier avec paramètre gDossier dans l'url, exemple http://localhost/noalyss/html/test.php?gDossier=25";
53 exit();
54}
57$cn=Dossier::connect();
58
60$g_user=new Noalyss_user($cn);
61
62if (!file_exists('authorized_debug'))
63{
64 echo "Pour pouvoir utiliser ce fichier vous devez creer un fichier nomme authorized_debug
65 dans le repertoire html du server";
66 exit();
67}
68define('ALLOWED', 1);
69
71
72/*
73 * Find all the folders
74 */
75$directory=NOALYSS_BASE."/scenario";
78
79for ($i=0; $i<$nb_folder;$i++)
80{
81 if (is_dir("{$directory}/".$folder[$i]) && $folder[$i] != '.' && $folder[$i] !='..')
82 {
84
85 }
86}
87
89
90/******************************************************************************************************************/
91/* Utilities */
92/******************************************************************************************************************/
93
94/**
95 * Return the card this most activities
96 * @return integer (fiche.f_id)
97 */
99 global $cn;
100 $card_count=$cn->get_array("select count(*),f_id ".
101 " from jrnx ".
102 " where ".
103 " f_id is not null ".
104 "group by f_id order by count(*) desc");
105 return $card_count[0]['f_id'];
106}
107
108/*
109 * Loading of all scenario HTML + XML
110 */
112{
113 $scan=scandir($directory);
114 $maxscan=count($scan);
115 $cnt_scenario=0;$scenario=array();
116
117 for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
118 {
119 if (is_file("{$directory}/".$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true)
120 {
121 $description="";
122 $a_description=file("{$directory}/".$scan[$e_scan]);
123 $max_description=count($a_description);
124 for ($w=0; $w<$max_description; $w++)
125 {
126 if (strpos($a_description[$w], '@description:')==true)
127 {
128 $description=$a_description[$w];
129 $description=noalyss_str_replace('//@description:', '', $description);
130 }
131 }
132 $scenario[$cnt_scenario]['file']="{$directory}/".$scan[$e_scan];
133 $scenario[$cnt_scenario]['desc']=$description;
134 $cnt_scenario++;
135
136
137 }
138 }
139 return $scenario;
140}
142{
143
144 echo h1($title);
145
146 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts",'module'=>$title));
147
148 echo '<table style="collapse: false;border-spacing: 1rem">';
149 echo '<tr>';
150 echo '<td>';
151 echo '<a href="'.$get.'" target="_blank">';
152 echo "Tous les tests du module $title ";
153 echo '</a>';
154 echo '</td>';
155 echo '<td>';
156 echo '<a href="'.$get.'" target="_blank">';
157 echo 'Tous les scripts';
158 echo '</a>';
159 echo '</td>';
160 echo '</tr>';
161 $nb_html=count($aHtml_files);
162 for ($e=0; $e<$nb_html; $e++)
163 {
164
165 $get='test.php?'.http_build_query(array('script'=>$aHtml_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$aHtml_files[$e]['desc']));
166 echo '<tr>';
167 echo '<td>';
168 echo $e;
169 echo '</td>';
170 echo '<td>';
171 echo '<a href="'.$get.'" target="_blank">';
172 echo basename($aHtml_files[$e]['file']);
173 echo '</a>';
174 echo '</td>';
175 echo '<td>'.$aHtml_files[$e]['desc'].'</td>';
176 echo '</tr>';
177
178 }
179 echo '</table>';
180}
181
182
183
184$script=$http->request('script', "string",'');
185$min=$cn->get_value("select p_id from parm_periode order by p_start asc limit 1");
186$max=$cn->get_value("select p_id from parm_periode order by p_start desc limit 1");
187printf ("Max période %s Min période %s",$max,$min);
188
189if ($script=="")
190{
191 echo "<h1>Test NOALYSS</h1>";
192 /*
193 * cherche pour fichier a include, s'il y en a alors les affiche
194 * avec une description
195 */
196
197 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
198 print '<p class="alert-primary p-2 w-50">';
199 printf( '<a href="%s" target="_blank"> Tous les test </a>',$get);
200 print '</p>';
201 foreach ($aAvaible_module as $mod) {
202 $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod);
203 display_test($mod,$gDossierLogInput,$html_files);
204
205 }
206
207
208}
209else if ($script=='all')
210{
211 $nb=$http->get('nb_script', "number",1);
212
213 $start_mem=memory_get_usage();
214 $start_time=microtime(true);
215 $module=$http->get('module','string','all');
216 $scenario=[];
217 if ($module=='all') {
218 foreach ($aAvaible_module as $mod) {
219 $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod);
220 $scenario = array_merge($html_files, $scenario);
221 }
222 } elseif (in_array($module, $aAvaible_module) ) {
223 $scenario=retrieve_files(NOALYSS_BASE.'/scenario/'.$module);
224
225 }
226
227 $maxscan=$http->get('nb_script', "number",count($scenario)-1);
228 $maxscan++;
229 for ($i=$nb;$i< $maxscan;$i++) {
230 echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
231 echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
232 include $scenario[$nb]['file'];
233 echo '</div>';
234 echo '</div>';
235 $end_mem=memory_get_usage();
236 $end_time=microtime(true);
237
238 echo "<p>start mem : ".$start_mem;
239 echo '</p>';
240 echo "<p>end mem : ".$end_mem;
241 echo '</p>';
242 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
243 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
244 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
245 echo '</p>';
246 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
247 $nb++;
248 if ( $nb == $maxscan ) {
249 echo "Dernier test";
250 } else {
251 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
252 echo '<a href="'.$get.'" target="_blank">';
253 echo $scenario[$nb]['file'];
254 echo '</a>';
255 }
256 }
257}
258else
259{
260 $start_mem=memory_get_usage();
261 $start_time=microtime(true);
262 $description=$http->get("description","string", "aucune description");
263 echo '<h1>'.$script."</h1>";
264 echo '<p> description = '.$description.'<p>';
265 include $script;
266
267 $end_mem=memory_get_usage();
268 $end_time=microtime(true);
269
270 echo "<p>start mem : ".$start_mem;
271 echo '</p>';
272 echo "<p>end mem : ".$end_mem;
273 echo '</p>';
274 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
275 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
276 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
277 echo '</p>';
278 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
279}
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
echo_warning($p_string)
warns
p($p_string, $p_extra='')
Definition ac_common.php:39
h1($p_string, $p_class="")
Definition ac_common.php:72
noalyss_str_replace($search, $replace, $string)
global $g_parameter
global $g_user
if no group available , then stop
if($gDossier==-1) $gDossierLogInput
Definition ajax_test.php:47
foreach($array as $idx=> $m) $w
_("actif, passif,charge,...")
manage the http input (get , post, request) and extract from an array
Class to manage the company parameter (address, name...)
global $g_failed
global $g_succeed
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
foreach(array('magic_quotes_gpc', 'magic_quotes_runtime') as $a) $module
Definition install.php:411
print
Type of printing.
if( $delta< 0) elseif( $delta==0)
$script
Definition popup.php:131
$end_mem
Definition test.php:267
retrieve_files($directory)
Definition test.php:111
$directory
Definition test.php:75
$end_time
Definition test.php:268
$nb_folder
Definition test.php:77
$folder
Definition test.php:76
$start_time
Definition test.php:261
get_card_with_activity()
Return the card this most activities.
Definition test.php:98
global $aAvaible_module
Definition test.php:70
display_test($title, $gDossierLogInput, $aHtml_files)
Definition test.php:141