noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
test.php File Reference

this file let you debug and test the different functionnalities, there are 2 important things to do It is only a quick and dirty testing. You should use a tool as PHPUNIT for the unit testing More...

Go to the source code of this file.

Functions

 display_test ($title, $gDossierLogInput, $aHtml_files)
 
 get_card_with_activity ()
 Return the card this most activities.
 
 retrieve_files ($directory)
 

Variables

global $aAvaible_module
 
global $cn =Dossier::connect()
 
 $description =$http->get("description","string", "aucune description")
 
 $directory =NOALYSS_BASE."/scenario"
 
 $end_mem =memory_get_usage()
 
 $end_time =microtime(true)
 
 $folder =scandir($directory)
 
global $g_failed
 
 $g_parameter =new Noalyss_Parameter_Folder($cn)
 
global $g_succeed
 
global $g_user =new Noalyss_user($cn)
 
if(ini_get('zend.assertions') !=1) $gDossier =$http->request('gDossier',"number", -1)
 
if($gDossier==-1) $gDossierLogInput =$gDossier
 
global $http =new HttpInput()
 
 $max =$cn->get_value("select p_id from parm_periode order by p_start desc limit 1")
 
 $min =$cn->get_value("select p_id from parm_periode order by p_start asc limit 1")
 
 $nb_folder =count($folder)
 
 $script =$http->request('script', "string",'')
 
 $start_time =microtime(true)
 
const ALLOWED (!file_exists('authorized_debug')) 1
 
if( $script=="") else if($script=='all') else
 
const TEST_UNIT 1
 

Detailed Description

this file let you debug and test the different functionnalities, there are 2 important things to do It is only a quick and dirty testing. You should use a tool as PHPUNIT for the unit testing

  • first do not forget to create the authorized_debug file in the html folder
  • 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 if the $_REQUEST[test_select] is not set, so set it .

Definition in file test.php.

Function Documentation

◆ display_test()

display_test ( $title,
$gDossierLogInput,
$aHtml_files )

Definition at line 141 of file test.php.

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}
h1($p_string, $p_class="")
Definition ac_common.php:72
if($gDossier==-1) $gDossierLogInput
Definition ajax_test.php:47
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
$end_time
Definition test.php:268
$start_time
Definition test.php:261
global $aAvaible_module
Definition test.php:70
display_test($title, $gDossierLogInput, $aHtml_files)
Definition test.php:141

References $e, $gDossierLogInput, $title, and h1().

+ Here is the call graph for this function:

◆ get_card_with_activity()

get_card_with_activity ( )

Return the card this most activities.

Returns
integer (fiche.f_id)

Definition at line 98 of file test.php.

98 {
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}

References $cn.

◆ retrieve_files()

retrieve_files ( $directory)

Definition at line 111 of file test.php.

111 :array
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}
noalyss_str_replace($search, $replace, $string)
foreach($array as $idx=> $m) $w
$directory
Definition test.php:75

References $description, $directory, $w, and noalyss_str_replace().

+ Here is the call graph for this function:

Variable Documentation

◆ $aAvaible_module

global $aAvaible_module

Definition at line 70 of file test.php.

◆ $cn

$cn =Dossier::connect()

Definition at line 56 of file test.php.

◆ $description

$description =$http->get("description","string", "aucune description")

Definition at line 262 of file test.php.

◆ $directory

$directory =NOALYSS_BASE."/scenario"

Definition at line 75 of file test.php.

Referenced by retrieve_files(), and Noalyss\Widget\Widget\scanfolder().

◆ $end_mem

$end_mem =memory_get_usage()

Definition at line 267 of file test.php.

◆ $end_time

$end_time =microtime(true)

Definition at line 268 of file test.php.

◆ $folder

$folder =scandir($directory)

Definition at line 76 of file test.php.

Referenced by Noalyss_Appearance\print_css().

◆ $g_failed

global $g_failed

Definition at line 56 of file test.php.

◆ $g_parameter

$g_parameter =new Noalyss_Parameter_Folder($cn)

Definition at line 59 of file test.php.

◆ $g_succeed

global $g_succeed

Definition at line 56 of file test.php.

◆ $g_user

$g_user =new Noalyss_user($cn)

Definition at line 56 of file test.php.

◆ $gDossier

if (ini_get( 'zend.assertions') !=1) $gDossier =$http->request('gDossier',"number", -1)

Definition at line 49 of file test.php.

◆ $gDossierLogInput

if ( $gDossier==-1) $gDossierLogInput =$gDossier

Definition at line 55 of file test.php.

◆ $http

$http =new HttpInput()

Definition at line 40 of file test.php.

◆ $max

$max =$cn->get_value("select p_id from parm_periode order by p_start desc limit 1")

Definition at line 186 of file test.php.

◆ $min

$min =$cn->get_value("select p_id from parm_periode order by p_start asc limit 1")

Definition at line 185 of file test.php.

◆ $nb_folder

$nb_folder =count($folder)

Definition at line 77 of file test.php.

Referenced by Dossier\count().

◆ $script

$script =$http->request('script', "string",'')

Definition at line 184 of file test.php.

◆ $start_time

$start_time =microtime(true)

Definition at line 261 of file test.php.

◆ ALLOWED

const ALLOWED(!file_exists( 'authorized_debug')) ( ! file_exists 'authorized_debug') 1

Definition at line 68 of file test.php.

◆ else

if($script=="") else if ( $script=='all') else
Initial value:
{
$start_mem=memory_get_usage()

Definition at line 258 of file test.php.

◆ TEST_UNIT

const TEST_UNIT 1

Definition at line 41 of file test.php.