Task #1044 - Implementation de Test

Test files : ajout ajax
This commit is contained in:
Dany De Bontridder 2014-11-15 17:04:09 +01:00
parent e8b5d52db7
commit 0b4ecc56a7
6 changed files with 179 additions and 74 deletions

View file

@ -53,7 +53,7 @@
* - ref if we want to refresh the window
*\see fiche fiche::Save constant.php
*/
define ('ALLOWED',1);
if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once('class_database.php');
@ -94,6 +94,24 @@ $g_user=new User($cn);
$g_user->check(true);
$g_user->check_dossier($gDossier,true);
$html=var_export($_REQUEST,true);
if ( LOGINPUT)
{
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"<?php \n");
fwrite ($file_loginput,'//@description:'.$op."\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST='.var_export($_POST,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
fwrite($file_loginput,"\n");
fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
fclose($file_loginput);
}
switch($op)
{
/* ------------------------------------------------------------ */
@ -519,13 +537,15 @@ case 'upc':
}
}
} // switch
$html=escape_xml($html);
$xml=escape_xml($html);
if (DEBUG && headers_sent()) {
echo $html;return;
}
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>$ctl</ctl>
<code>$html</code>
<code>$xml</code>
</data>
EOF;

View file

@ -23,6 +23,8 @@
* \brief show the history of a card of an accounting
* for the card f_id is set and for an accounting : pcm_val
*/
if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once('class_database.php');
require_once('class_user.php');
@ -33,7 +35,6 @@ require_once('class_acc_account.php');
require_once('class_exercice.php');
$div=$_REQUEST['div'];
mb_internal_encoding("UTF-8");
define ('ALLOWED',1);
/**
*if $_SESSION['g_user'] is not set : echo a warning
@ -46,7 +47,24 @@ $g_user=new User($cn);
if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit();
$from_div = (isset($_REQUEST['ajax'])) ? 1 : $_GET['l'];
if ( LOGINPUT)
{
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"<?php \n");
fwrite ($file_loginput,"//@description:\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST='.var_export($_POST,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
fwrite($file_loginput,"\n");
fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
fclose($file_loginput);
}
///////////////////////////////////////////////////////////////////////////
/* first detail for a card */
///////////////////////////////////////////////////////////////////////////
@ -189,12 +207,15 @@ if ( isset($_REQUEST['pcm_val']))
ob_end_clean();
}
}
$html=escape_xml($html);
$xml=escape_xml($html);
if (DEBUG && headers_sent()) {
echo $html;return;
}
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>$div</ctl>
<code>$html</code>
<code>$xml</code>
</data>
EOF;

View file

@ -28,7 +28,8 @@
- for reconcialiation
- update of analytic content
*/
define ('ALLOWED',1);
if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once('class_database.php');
require_once('class_user.php');
@ -63,7 +64,24 @@ ajax_disconnected($div);
$cn=new Database(dossier::id());
$g_parameter=new Own($cn);
if ( LOGINPUT)
{
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"<?php \n");
fwrite ($file_loginput,'//@description:'.$action."\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST='.var_export($_POST,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
fwrite($file_loginput,"\n");
fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
fclose($file_loginput);
}
// check if the user is valid and can access this folder
global $g_user;
$g_user=new User($cn);

View file

@ -34,7 +34,8 @@
* dl : display form to modify, add and delete lettering for a given operation
*
*/
define ('ALLOWED',1);
if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once('class_database.php');
require_once ('class_fiche.php');
@ -69,6 +70,24 @@ if ($gDossier<>0) {
}
$html = var_export($_REQUEST, true);
if ( LOGINPUT)
{
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"<?php \n");
fwrite ($file_loginput,'//@description:'.$op."\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST='.var_export($_POST,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
fwrite($file_loginput,"\n");
fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
fclose($file_loginput);
}
switch ($op)
{
case "remove_anc":

View file

@ -32,7 +32,8 @@
*
*
*/
define ('ALLOWED',1);
if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once ("ac_common.php");
require_once('class_acc_ledger.php');
@ -65,7 +66,24 @@ $g_user=new User($cn);
$g_user->Check();
if ($g_user->check_dossier(dossier::id()) == 'X') exit();
$xml="";
if ( LOGINPUT)
{
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
fwrite ($file_loginput,"<?php \n");
fwrite ($file_loginput,'//@description:'.$op."\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST='.var_export($_POST,true));
fwrite($file_loginput,";\n");
fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
fwrite($file_loginput,"\n");
fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
fwrite($file_loginput,"\n");
fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
fclose($file_loginput);
}
switch ($op)
{
/*----------------------------------------------------------------------

View file

@ -58,63 +58,15 @@ if (!file_exists('authorized_debug'))
}
define('ALLOWED', 1);
html_page_start();
$script=HtmlInput::default_value_get('script', '');
if ($script=="")
{
echo "<h1>Test NOALYSS</h1>";
/*
* cherche pour fichier a include, s'il y en a alors les affiche
* avec une description
*/
$scan=scandir('../scenario/');
$max=count($scan);
echo '<table>';
$get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
echo '<tr>';
echo '<td>';
echo '<a href="'.$get.'" target="_blank">';
echo "Tous ";
echo '</a>';
echo '</td>';
echo '<td>Tous les scripts</td>';
echo '</tr>';
/*
* Loading of all scenario
*/
$scan=scandir('../scenario/');
$maxscan=count($scan);
$cnt_scenario=0;$scenario=array();
for ($e=0; $e<$max; $e++)
{
if (is_file('../scenario/'.$scan[$e])&&strpos($scan[$e], '.php')==true)
{
$description="";
$a_description=file('../scenario/'.$scan[$e]);
$max_description=count($a_description);
for ($w=0; $w<$max_description; $w++)
{
if (strpos($a_description[$w], '@description:')==true)
{
$description=$a_description[$w];
$description=str_replace('//@description:', '', $description);
}
}
$get='test.php?'.http_build_query(array('script'=>$scan[$e], 'gDossier'=>$gDossierLogInput, 'description'=>$description));
echo '<tr>';
echo '<td>';
echo '<a href="'.$get.'" target="_blank">';
echo $scan[$e];
echo '</a>';
echo '</td>';
echo '<td>'.$description.'</td>';
echo '</tr>';
}
}
echo '</table>';
}
else if ($script=='all')
{
$scan=scandir('../scenario/');
$maxscan=count($scan);
echo '<table>';
for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
{
if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan], '.php')==true)
{
@ -129,13 +81,64 @@ else if ($script=='all')
$description=str_replace('//@description:', '', $description);
}
}
$scenario[$cnt_scenario]['file']=$scan[$e_scan];
$scenario[$cnt_scenario]['desc']=$description;
$cnt_scenario++;
}
}
$script=HtmlInput::default_value_get('script', '');
if ($script=="")
{
echo "<h1>Test NOALYSS</h1>";
/*
* cherche pour fichier a include, s'il y en a alors les affiche
* avec une description
*/
echo '<table>';
$get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
echo '<tr>';
echo '<td>';
echo '<a href="'.$get.'" target="_blank">';
echo "Tous ";
echo '</a>';
echo '</td>';
echo '<td>Tous les scripts</td>';
echo '</tr>';
for ($e=0; $e<$cnt_scenario; $e++)
{
$get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc']));
echo '<tr>';
echo '<td>';
echo $e;
echo '</td>';
echo '<td>';
echo '<a href="'.$get.'" target="_blank">';
echo $scenario[$e]['file'];
echo '</a>';
echo '</td>';
echo '<td>'.$scenario[$e]['desc'].'</td>';
echo '</tr>';
}
echo '</table>';
}
else if ($script=='all')
{
$nb=HtmlInput::default_value_get('nb_script', 0);
$start_mem=memory_get_usage();
$start_time=microtime(true);
$script=str_replace('../', '', $script);
echo '<h1>'.$script."</h1>";
echo '<h2> description = '.$description.'</h2>';
include '../scenario/'.$scan[$e_scan];
echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
include '../scenario/'.$scenario[$nb]['file'];
echo '</div>';
echo '</div>';
$end_mem=memory_get_usage();
@ -150,8 +153,14 @@ else if ($script=='all')
echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes ";
echo '</p>';
echo "<p>Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes</p>";
}
}
$nb++;
if ( $nb == $maxscan ) {
echo "Dernier test";
} else {
$get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
echo '<a href="'.$get.'" target="_blank">';
echo $scenario[$nb]['file'];
}
}
else
{