noalyss Version-9
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
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}
55$cn=Dossier::connect();
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
69// To enable assert , set "zend.assertions" in the php.ini file
70// deprecated PHP8.3
71//ini_set("assert.active",1);
72//assert_options(ASSERT_ACTIVE, 1);
73//assert_options(ASSERT_WARNING, 1);
74//removed in PHP8 assert_options(ASSERT_QUIET_EVAL, 1);
75//
76//function my_assert_handler($file, $line, $code)
77//{
78// echo "<hr>Assert Failed :
79// File '$file'<br />
80// Line '$line'<br />
81// Code '$code'<br /><hr />";
82//}
83//assert_options(ASSERT_CALLBACK, 'my_assert_handler');
84/******************************************************************************************************************/
85/* Utilities
86/******************************************************************************************************************/
87
88/**
89 * Return the card this most activities
90 * @return integer (fiche.f_id)
91 */
93 global $cn;
94 $card_count=$cn->get_array("select count(*),f_id ".
95 " from jrnx ".
96 " where ".
97 " f_id is not null ".
98 "group by f_id order by count(*) desc");
99 return $card_count[0]['f_id'];
100}
101
102/*
103 * Loading of all scenario
104 */
105$scan=scandir('../scenario/');
108
109for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
110 {
111 if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true)
112 {
113 $description="";
114 $a_description=file('../scenario/'.$scan[$e_scan]);
115 $max_description=count($a_description);
116 for ($w=0; $w<$max_description; $w++)
117 {
118 if (strpos($a_description[$w], '@description:')==true)
119 {
120 $description=$a_description[$w];
121 $description=noalyss_str_replace('//@description:', '', $description);
122 }
123 }
124 $scenario[$cnt_scenario]['file']=$scan[$e_scan];
127
128
129 }
130 }
131$script=$http->request('script', "string",'');
132$min=$cn->get_value("select p_id from parm_periode order by p_start asc limit 1");
133$max=$cn->get_value("select p_id from parm_periode order by p_start desc limit 1");
134printf ("Max période %s Min période %s",$max,$min);
135
136if ($script=="")
137{
138 echo "<h1>Test NOALYSS</h1>";
139 /*
140 * cherche pour fichier a include, s'il y en a alors les affiche
141 * avec une description
142 */
143
144
145 echo '<table>';
146 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
147 echo '<tr>';
148 echo '<td>';
149 echo '<a href="'.$get.'" target="_blank">';
150 echo "Tous ";
151 echo '</a>';
152 echo '</td>';
153 echo '<td>Tous les scripts</td>';
154 echo '</tr>';
155
156 for ($e=0; $e<$cnt_scenario; $e++)
157 {
158
159 $get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc']));
160 echo '<tr>';
161 echo '<td>';
162 echo $e;
163 echo '</td>';
164 echo '<td>';
165 echo '<a href="'.$get.'" target="_blank">';
166 echo $scenario[$e]['file'];
167 echo '</a>';
168 echo '</td>';
169 echo '<td>'.$scenario[$e]['desc'].'</td>';
170 echo '</tr>';
171
172 }
173 echo '</table>';
174}
175else if ($script=='all')
176{
177 $nb=$http->get('nb_script', "number",0);
178
179 $start_mem=memory_get_usage();
180 $start_time=microtime(true);
182
183 echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
184 echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
185 include '../scenario/'.$scenario[$nb]['file'];
186 echo '</div>';
187 echo '</div>';
188 $end_mem=memory_get_usage();
189 $end_time=microtime(true);
190
191 echo "<p>start mem : ".$start_mem;
192 echo '</p>';
193 echo "<p>end mem : ".$end_mem;
194 echo '</p>';
195 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
196 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
197 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
198 echo '</p>';
199 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
200 $nb++;
201 if ( $nb == $maxscan ) {
202 echo "Dernier test";
203 } else {
204 $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
205 echo '<a href="'.$get.'" target="_blank">';
206 echo $scenario[$nb]['file'];
207 }
208}
209else
210{
211 $start_mem=memory_get_usage();
212 $start_time=microtime(true);
214 $description=$http->get("description","string", "aucune description");
215 echo '<h1>'.$script."</h1>";
216 echo '<p> description = '.$description.'<p>';
217 include '../scenario/'.$script;
218
219 $end_mem=memory_get_usage();
220 $end_time=microtime(true);
221
222 echo "<p>start mem : ".$start_mem;
223 echo '</p>';
224 echo "<p>end mem : ".$end_mem;
225 echo '</p>';
226 echo "<p>Diff = ".($end_mem-$start_mem)." bytes ";
227 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes ";
228 echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
229 echo '</p>';
230 echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
231}
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
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
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
$script
Definition popup.php:125
$end_mem
Definition test.php:219
$scan
Definition test.php:105
$maxscan
Definition test.php:106
$end_time
Definition test.php:220
$start_time
Definition test.php:212
$scenario
Definition test.php:107
get_card_with_activity()
Return the card this most activities.
Definition test.php:92
$cnt_scenario
Definition test.php:107