noalyss Version-9
Functions | Variables
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

 get_card_with_activity ()
 Return the card this most activities. More...
 
 my_assert_handler ($file, $line, $code)
 

Variables

global $cn =Dossier::connect()
 
 $cnt_scenario =0
 
 $description =$http->get("description","string", "aucune description")
 
 $end_mem =memory_get_usage()
 
 $end_time =microtime(true)
 
global $g_failed
 
 $g_parameter =new Noalyss_Parameter_Folder($cn)
 
global $g_succeed
 
global $g_user =new Noalyss_user($cn)
 
 $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")
 
 $maxscan =count($scan)
 
 $min =$cn->get_value("select p_id from parm_periode order by p_start asc limit 1")
 
 $scan =scandir('../scenario/')
 
 $scenario =array()
 
for($e_scan=0; $e_scan< $maxscan; $e_scan++) $script =$http->request('script', "string",'')
 
 $start_time =microtime(true)
 
const ALLOWED (!file_exists('authorized_debug')) 1
 
if( $script=="") else if($script=='all') else
 

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

Definition in file test.php.

Function Documentation

◆ get_card_with_activity()

get_card_with_activity ( )

Return the card this most activities.

Returns
integer (fiche.f_id)

Definition at line 89 of file test.php.

89 {
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/');
103$maxscan=count($scan);
104$cnt_scenario=0;$scenario=array();
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}
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
foreach($array as $idx=> $m) $w
$end_mem
Definition: test.php:216
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
$description
Definition: test.php:211
$max
Definition: test.php:130
$cnt_scenario
Definition: test.php:104
for($e_scan=0; $e_scan< $maxscan; $e_scan++) $script
Definition: test.php:128

References $cn.

◆ my_assert_handler()

my_assert_handler (   $file,
  $line,
  $code 
)

Definition at line 73 of file test.php.

74{
75 echo "<hr>Assert Failed :
76 File '$file'<br />
77 Line '$line'<br />
78 Code '$code'<br /><hr />";
79}

Variable Documentation

◆ $cn

Definition at line 54 of file test.php.

Referenced by get_card_with_activity().

◆ $cnt_scenario

$cnt_scenario =0

Definition at line 104 of file test.php.

◆ $description

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

Definition at line 211 of file test.php.

◆ $end_mem

$end_mem =memory_get_usage()

Definition at line 216 of file test.php.

◆ $end_time

$end_time =microtime(true)

Definition at line 217 of file test.php.

◆ $g_failed

global $g_failed

Definition at line 54 of file test.php.

◆ $g_parameter

$g_parameter =new Noalyss_Parameter_Folder($cn)

Definition at line 57 of file test.php.

◆ $g_succeed

global $g_succeed

Definition at line 54 of file test.php.

◆ $g_user

$g_user =new Noalyss_user($cn)

Definition at line 54 of file test.php.

◆ $gDossier

$gDossier =$http->request('gDossier',"number", -1)

Definition at line 47 of file test.php.

◆ $gDossierLogInput

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

Definition at line 53 of file test.php.

◆ $http

$http =new HttpInput()

Definition at line 42 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 130 of file test.php.

◆ $maxscan

$maxscan =count($scan)

Definition at line 103 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 129 of file test.php.

◆ $scan

$scan =scandir('../scenario/')

Definition at line 102 of file test.php.

◆ $scenario

$scenario =array()

Definition at line 104 of file test.php.

◆ $script

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

Definition at line 128 of file test.php.

◆ $start_time

$start_time =microtime(true)

Definition at line 209 of file test.php.

◆ ALLOWED

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

Definition at line 66 of file test.php.

◆ else

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

Definition at line 206 of file test.php.