From e26f1ee290f3925cdbfe109a654552d1009c9526 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 18 Feb 2024 17:58:47 +0100 Subject: [PATCH 1/7] PHP8.1 compatibility --- include/template/ledger_detail_misc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index 57fe1f5e9..15944d7f7 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -41,7 +41,7 @@ $owner = new Noalyss_Parameter_Folder($cn); value=strip_tags($obj->det->jr_comment); + $itext->value=strip_tags($obj->det->jr_comment??""); $itext->size=40; echo td(_('Libellé')).td($itext->input()); From 1c6fcf0561b027caff9c7b653c1a06f20aa529a5 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 18 Feb 2024 17:59:21 +0100 Subject: [PATCH 2/7] If card already used in accountancy, cannot changed the quickcode --- include/class/card_property.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index 7a30159c7..58c7f73d0 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -494,11 +494,14 @@ class Card_Property } // Special traitement - // quickcode + // quickcode , if already used in ledger , it cannot be changed if ($value->ad_id==ATTR_DEF_QUICKCODE) { - $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text)); - $p_fiche->cn->exec_sql($sql); + $used = $p_fiche->cn->get_value("select count(*) from jrnx where j_qcode= $1",[$value->av_text]); + if ($used == 0) { + $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text)); + $p_fiche->cn->exec_sql($sql); + } continue; } // name From b5213f3308d1776fbaaa2b625ad5b316af4826cc Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 19 Feb 2024 16:33:40 +0100 Subject: [PATCH 3/7] QCODE : remove trigger update on jrnx --- sql/reverse.sql | 2 ++ sql/upgrade.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/sql/reverse.sql b/sql/reverse.sql index 8b1378917..351d24900 100644 --- a/sql/reverse.sql +++ b/sql/reverse.sql @@ -1 +1,3 @@ +create trigger t_jrnx_upd before update on + public.jrnx for each row execute function jrnx_ins(); \ No newline at end of file diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..0e7d7a6d5 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1 @@ +DROP TRIGGER t_jrnx_upd ON public.jrnx; From 8c3cbda94f00bc69c8a8a25d84eb064f7931703b Mon Sep 17 00:00:00 2001 From: Dany wm Date: Mon, 19 Feb 2024 19:21:54 +0100 Subject: [PATCH 4/7] FOLLOWUP : change destinataire et concerne, supprime filtre sur "concerne" --- include/class/follow_up.class.php | 2 +- include/template/follow_up-display.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 2821a1ee3..78ba17393 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -351,7 +351,7 @@ class Follow_Up $w->name='qcode_dest'; $w->value=($this->f_id_dest!=0)?$this->qcode_dest:""; $w->label=""; - $list_recipient=$this->db->make_list('select fd_id from fiche_def where frd_id in (14,25,8,9,16)'); + $list_recipient=$this->db->make_list('select fd_id from fiche_def'); $w->extra=$list_recipient; $w->set_attribute('typecard', $list_recipient); $w->set_dblclick("fill_ipopcard(this);"); diff --git a/include/template/follow_up-display.php b/include/template/follow_up-display.php index f90818fad..fe090fb2e 100644 --- a/include/template/follow_up-display.php +++ b/include/template/follow_up-display.php @@ -43,7 +43,7 @@ $dossier_id=Dossier::id(); - + search().$w->input(); From 85f19810ad81cf29f2b4e58cc05268f667d73d00 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Wed, 21 Feb 2024 20:44:29 +0100 Subject: [PATCH 5/7] Bug : verification ne fonctionne pas avec MY_REPORT=N --- include/constant.php | 1 + include/verif_bilan.inc.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/constant.php b/include/constant.php index cc2868b6d..f05eb71f9 100644 --- a/include/constant.php +++ b/include/constant.php @@ -171,6 +171,7 @@ if (DEBUGNOALYSS == 0) { ini_set('log_errors', 1); ini_set('log_errors_max_len', 0); + } // Erreur define("NOERROR", 0); diff --git a/include/verif_bilan.inc.php b/include/verif_bilan.inc.php index 9c66783dc..05e90e595 100644 --- a/include/verif_bilan.inc.php +++ b/include/verif_bilan.inc.php @@ -108,8 +108,16 @@ echo '

'._('Vérification des comptes' $bilan=new Acc_Bilan($cn); $periode=new Periode($cn); list ($start_periode,$end_periode)=$periode->get_limit($exercice); -$bilan->from=$start_periode->p_id; -$bilan->to=$end_periode->p_id; +global $g_parameter; +if ( $g_parameter->MY_REPORT=="Y") { + $bilan->from=$start_periode->p_id; + $bilan->to=$end_periode->p_id; + +} else { + $first_periode=$cn->get_value("select to_char(p_start,'YYYY-MM-DD') from parm_periode order by p_start limit 1"); + $bilan->from=format_date($first_periode,'YYYY-MM-DD','DD.MM.YYYY'); + $bilan->to=$end_periode->last_day(); +} $bilan->verify(); echo '

'; ?> From 4496e09703f7956c1a425950b185f47aae30cd6e Mon Sep 17 00:00:00 2001 From: Dany wm Date: Tue, 20 Feb 2024 20:55:09 +0100 Subject: [PATCH 6/7] Saved search for accountancy replace filter by "Saved search" --- html/ajax_misc.php | 2 + html/js/acc_ledger.js | 22 ++++ include/ajax/ajax_search_filter.php | 29 +++-- include/class/acc_ledger_search.class.php | 52 ++++++++- include/history_operation.inc.php | 47 ++++---- .../acc_ledger_search-display_list_filter.php | 103 ++++++++++++++++++ .../follow_up_filter-display_list.php | 4 +- 7 files changed, 225 insertions(+), 34 deletions(-) create mode 100644 include/template/acc_ledger_search-display_list_filter.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 5e1261b5b..e79e3b0f8 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -266,6 +266,8 @@ $path = array( "save_filter"=>"ajax_search_filter", // Load a search filter "load_filter"=>"ajax_search_filter", + // display a list of filter (alias saved search) + "display_list_filter"=>"ajax_search_filter", // display tag for filter 'display_filter_tag'=>'ajax_search_filter', // search operation to reconcile diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 6298d53ad..7ca3b0422 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1672,6 +1672,28 @@ function reset_filter(p_div) { // By default , unpaid is uncked $(p_div + "operation_filter").value = "all"; } +function display_list_filter(p_dossier,access_code,ledger_type) +{ + new Ajax.Request("ajax_misc.php",{ + parameters:{"gDossier":p_dossier + ,"op":"display_list_filter" + ,"ac":access_code + ,'ledger_type':ledger_type + }, + method:'GET', + onSuccess: function (responseHtml) { + try { + var posy=calcy(250) + var div = create_div({"id":"display_list_filter_div", + 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"}); + div.update(responseHtml.responseText); + div.show(); + }catch (e) { + console.error(e.message); + } + } + }) +} /** * propose to duplicate an operation diff --git a/include/ajax/ajax_search_filter.php b/include/ajax/ajax_search_filter.php index 7301c4ba3..e895707ad 100644 --- a/include/ajax/ajax_search_filter.php +++ b/include/ajax/ajax_search_filter.php @@ -111,13 +111,7 @@ if ($op=="load_filter") $answer['filter_id']=0; $answer['message']=""; $filter=new User_filter_SQL($cn, $filter_id); - $record=$filter->to_array(); - - $record['desc']=$record['description']; - $record['r_jrn']=explode(",", $record['r_jrn']??""); - $record['tag']=explode(",",$record['uf_tag']??""); - $record['tag_option']=$record["uf_tag_option"]; - $record['p_currency_code']=$record['uf_currency_code']; + $record=Acc_Ledger_Search::build_array($filter); $result=array_merge($answer, $record); @@ -227,4 +221,25 @@ if ($op=='display_filter_tag') $tag_operation->update_search_cell($div); } } + return; +} +//--------------------------------------------------------------------------------------------------------------- +// display_list_filter : display a list of saved search alias filter +//---------------------------------------------------------------------------------------------------------------- +if ($op=='display_list_filter') +{ + echo \HtmlInput::title_box("Recherches sauvées",'display_list_filter_div'); + + $ledger_search=new Acc_Ledger_Search($http->request("ledger_type")); + $ledger_search->display_list_filter(); +?> + + +
    +
  • + +
  • +
+div."filter_new"); - $name->placeholder=_("Nom du filtre"); + $name->placeholder=_("Nom de la recherche"); $r=$name->input(); $bt=new IButton($this->div."save_ok",_("Ajout")); $bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id()); @@ -724,7 +726,7 @@ class Acc_Ledger_Search $r.=HtmlInput::submit('search', _('Rechercher')); - $button_search=new IButton("{$this->div}button", _('Filtre')); + $button_search=new IButton("{$this->div}button", _('Recherches sauvées')); $button_search->javascript=$this->build_search_filter(); $r.=$button_search->input(); @@ -1313,4 +1315,48 @@ class Acc_Ledger_Search return $ret; } + /** + * @brief use a user_filter row and turns it into an array for + * javascript purpose + * @param User_Filter_SQL $user_filter_sql + * @return array + */ + static function build_array(User_Filter_SQL $user_filter_sql) + { + $record=$user_filter_sql->to_array(); + + $record['desc']=$record['description']; + $record['r_jrn']=explode(",", $record['r_jrn']??""); + $record['tag']=explode(",",$record['uf_tag']??""); + $record['tag_option']=$record["uf_tag_option"]; + $record['p_currency_code']=$record['uf_currency_code']; + return $record; + } + + /** + * @brief build an HTML string with a button to show the list of + * saved search + * @return string HTML button + * @throws Exception if $_REQUEST['ac'] is not set + */ + public function button_propose_filter() + { + $http=new HttpInput(); + $button=HtmlInput::button_action("Recherches sauvées", + sprintf("display_list_filter('%s','%s','%s')" + ,Dossier::id() + , $http->request("ac") + ,$this->type + ),uniqid(),'smallbutton'); + return $button; + } + + /** + * @brief display a list of saved search + */ + public function display_list_filter() + { + require_once NOALYSS_TEMPLATE."/acc_ledger_search-display_list_filter.php"; + + } } diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php index 56b8ab3c2..a983cd50a 100644 --- a/include/history_operation.inc.php +++ b/include/history_operation.inc.php @@ -32,31 +32,33 @@ global $g_user,$cn,$http; $p_array = $_GET; $ledger_type=$http->get("ledger_type","string", 'ALL'); -$Ledger=new Acc_Ledger_Search($ledger_type,0,'search_op'); switch($ledger_type) { - case 'ACH': - $ask_pay=1; - $p_array['ledger_type']='ACH'; - break; - case 'ODS': - $ask_pay=0; - $p_array['ledger_type']='ODS'; - break; - case 'ALL': - $ask_pay=0; - $p_array['ledger_type']='ALL'; - break; - case 'VEN': - $ask_pay=1; - $p_array['ledger_type']='VEN'; - break; - case 'FIN': - $ask_pay=0; - $p_array['ledger_type']='FIN'; - break; + case 'ACH': + $ask_pay=1; + $p_array['ledger_type']='ACH'; + break; + case 'ODS': + $ask_pay=0; + $p_array['ledger_type']='ODS'; + break; + case 'ALL': + $ask_pay=0; + $p_array['ledger_type']='ALL'; + break; + case 'VEN': + $ask_pay=1; + $p_array['ledger_type']='VEN'; + break; + case 'FIN': + $ask_pay=0; + $p_array['ledger_type']='FIN'; + break; + default: + throw new \Exception("HO58 : ledger_type unknown"); } +$Ledger=new Acc_Ledger_Search($p_array['ledger_type'],0,'search_op'); echo '
'; // Check privilege $p_jrn=$http->request("p_jrn", "string",-1); @@ -113,8 +115,9 @@ $offset=(isNumber($offset)==0)?0:$offset; $bar = navigation_bar($offset, $max_line, $step, $page); echo $msg; -echo $Ledger->display_search_form(); +echo $Ledger->button_propose_filter(); echo HtmlInput::filter_table('history_operation_t', '0,1,2,3,4,5,6,7', 1); +echo $Ledger->display_search_form(); echo $bar; echo '
'; echo HtmlInput::hidden("ac", $http->request('ac')); diff --git a/include/template/acc_ledger_search-display_list_filter.php b/include/template/acc_ledger_search-display_list_filter.php new file mode 100644 index 000000000..879b3589d --- /dev/null +++ b/include/template/acc_ledger_search-display_list_filter.php @@ -0,0 +1,103 @@ +cn->get_array("select id,filter_name,description,ledger_type +from public.user_filter where login=$1 and ledger_type=$2", +[$g_user->getLogin(),$this->type]); +$nb_array=count($array); +$http=new HttpInput(); +$div="search_op"; +?> +

+ Cliquez sur un lien pour affiche le résultat de la recherche +

+ + +
    + + +
  • + cn,$array[$i]["id"]); + + $a_param=array(); + $a_param["search_opnb_jrn"] = $user_filter->getp("nb_jrn"); + if ($a_param["search_opnb_jrn"] > 0 ) { + $a_param['search_opr_jrn']=explode(",",$user_filter->getp("r_jrn")); + } + $a_param ["date_start"] = $user_filter->getp("date_start"); + $a_param ["date_paid_start"] = $user_filter->getp("date_paid_start"); + $a_param ["date_paid_end"] = $user_filter->getp("date_paid_end"); + /*[search_opdate_start_hidden] => 01.01.2023 + [search_opdate_end_hidden] => 31.12.2023*/ + $a_param["desc"] =$user_filter->getp("description"); + $a_param["amount_min"] = $user_filter->getp("amount_min"); + $a_param["amount_max"] = $user_filter->getp("amount_max"); + $a_param["search_opqcode"] =$user_filter->getp("qcode"); + $a_param["accounting"] = $user_filter->getp("accounting"); + $a_param["tva_id_search"] = $user_filter->getp("tva_id_search"); + $a_param["operation_filter"] = $user_filter->getp("operation_filter"); + $a_param["p_currency_code"] = $user_filter->getp("uf_currency_code"); + $a_param["search_optag_option"] =$user_filter->getp("uf_tag_option"); + if ( $user_filter->getp("uf_tag") != "") { + $a_param["search_optag"]=explode(",",$user_filter->getp("uf_tag")); + } + $a_param['search_opqcode']=$user_filter->getp('qcode'); + $a_param['ledger_type']=$array[$i]['ledger_type']; + + $a_param['ac']=$http->request("ac"); + $a_param['gDossier']=$http->request("gDossier","number"); + $url="do.php?".http_build_query($a_param); + ?> + + + + + + +
  • + +
+
    +
  • + request("ac"); + $a_param['gDossier']=$http->request("gDossier","number"); + $url="do.php?".http_build_query($a_param); + ?> + + Aucun filtre + +
  • + +
diff --git a/include/template/follow_up_filter-display_list.php b/include/template/follow_up_filter-display_list.php index 01fe4f112..56abaafdd 100644 --- a/include/template/follow_up_filter-display_list.php +++ b/include/template/follow_up_filter-display_list.php @@ -35,7 +35,7 @@ from action_gestion_filter where af_user=$1 order by lower(af_name)", [$login]); if (count($a_list) == 0) { - echo_warning("Aucun filtre"); + echo_warning("Aucune recherche sauvée"); echo \HtmlInput::button_close($div); return; } @@ -43,7 +43,7 @@ if (count($a_list) == 0) { ?>

- Cliquer sur un filtre pour chercher + Cliquez sur un lien pour affiche le résultat de la recherche

Date: Thu, 22 Feb 2024 23:25:02 +0100 Subject: [PATCH 7/7] Code Improve : Extension , Fix : php8.1 --- include/class/acc_bilan.class.php | 6 +- include/class/extension.class.php | 48 +++++++- include/verif_bilan.inc.php | 5 +- unit-test/include/class/data/plugin.xml | 86 +++++++++++++ unit-test/include/class/extensiontest.php | 139 ++++++++++++++++++++++ 5 files changed, 273 insertions(+), 11 deletions(-) create mode 100644 unit-test/include/class/data/plugin.xml create mode 100644 unit-test/include/class/extensiontest.php diff --git a/include/class/acc_bilan.class.php b/include/class/acc_bilan.class.php index d39780f54..4993b1453 100644 --- a/include/class/acc_bilan.class.php +++ b/include/class/acc_bilan.class.php @@ -335,7 +335,7 @@ class Acc_Bilan } catch(Exception $Ex) { - record_log($e); + record_log($Ex); echo $Ex->getMessage(); throw $Ex; } @@ -437,7 +437,7 @@ class Acc_Bilan $zip->close(); } else { - echo __FILE__.":".__LINE__."cannot unzip model ".$filename; + echo __FILE__.":".__LINE__."cannot unzip model ".$file_base; } ob_end_clean(); @@ -738,7 +738,7 @@ class Acc_Bilan } else { - echo __FILE__.":".__LINE__."cannot unzip model ".$filename; + echo __FILE__.":".__LINE__."cannot unzip model ".$file_base; } // Remove the file we do not need anymore diff --git a/include/class/extension.class.php b/include/class/extension.class.php index bf60cbdad..6f1cdacf5 100644 --- a/include/class/extension.class.php +++ b/include/class/extension.class.php @@ -253,7 +253,7 @@ class Extension extends Menu_Ref_sql } /** - * remove all the schema from the plugins + * @brief remove all the standard plugins schema * @param Database $p_cn */ static function clean(Database $p_cn) @@ -269,7 +269,7 @@ class Extension extends Menu_Ref_sql } /** - * compare the version of the plugin and the last version , propose to update it if a new version exists + * @brief compare the version of the plugin and the last version , propose to update it if a new version exists * @todo add a mechanism to check once a day * @global User $g_user * @global number $version_plugin @@ -327,6 +327,9 @@ class Extension extends Menu_Ref_sql throw new Exception(_('Manque répertoire racine'), 1); if (!isset($xml->plugin[$i]->file)) throw new Exception(_('Manque fichier à inclure'), 1); + if (!isset($xml->plugin[$i]->version)) + throw new Exception(_("Manque version de l'extension"), 1); + if (!isset($xml->plugin[$i]->depend)) $xml->plugin[$i]->depend="EXT"; if (!isset($xml->plugin[$i]->order)) @@ -340,8 +343,9 @@ class Extension extends Menu_Ref_sql } /** - * Parse a XML file to complete an array of extension objects - * @brief Create extension from XML. + * @brief Parse a XML file to complete an array of extension objects, in the plugin.xml file , you can find + * several plugins sharing some parts. + * * @param string $p_file filename * @return array array of Extension */ @@ -363,7 +367,7 @@ class Extension extends Menu_Ref_sql } catch (Exception $ex) { - echo_warning($e->getMessage()); + echo_warning($ex->getMessage()); if ($ex->getCode()==1) { continue; @@ -378,14 +382,46 @@ class Extension extends Menu_Ref_sql $extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code); $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"EXT"; $extension->order=(isset($xml->plugin[$i]->order))?trim($xml->plugin[$i]->order):9000; + $extension->version=trim($xml->plugin[$i]->version); + $extension->noalyss_version=(isset($xml->plugin[$i]->noalyss_version))?trim($xml->plugin[$i]->noalyss_version):8000; $a_extension[]=clone $extension; } return $a_extension; } + /** + * @brief find the extension with the me_code = last part of access_code + * @param $a_extension + * @param $access_code find the ME_CODE (normally last part ) + * @return the extension or null + */ + public static function find_extension_code($a_extension,$access_code):Extension|null + { + $a_me_code=explode("/", $access_code); + if (empty($a_me_code ) ) return null; + $nb_me_code=count($a_me_code); + $me_code=$a_me_code[$nb_me_code-1]; + foreach ($a_extension as $extension) { + if ($extension->me_code==$me_code) return $extension; + } + return null; + } + public function __toString(): string { - return "Extension"; + $r = ""; + $r .= " me_code " . $this->me_code.PHP_EOL; + $r .= " me_menu.".$this->me_menu.PHP_EOL; + $r .= " version".$this->version.PHP_EOL; + $r .= " noalyss_version".$this->noalyss_version.PHP_EOL; + $r .= " me_file" . $this->me_file.PHP_EOL; + $r .= " me_url" . $this->me_url.PHP_EOL; + $r .= " me_description" . $this->me_description.PHP_EOL; + $r .= " me_parameter" . $this->me_parameter.PHP_EOL; + $r .= " me_javascript" . $this->me_javascript.PHP_EOL; + $r .= " me_type" . $this->me_type.PHP_EOL; + $r .= " me_descrition_etendue" . $this->me_description_etendue.PHP_EOL; + return "Extension $r"; } diff --git a/include/verif_bilan.inc.php b/include/verif_bilan.inc.php index 05e90e595..bff0737ec 100644 --- a/include/verif_bilan.inc.php +++ b/include/verif_bilan.inc.php @@ -175,9 +175,10 @@ having count(*) > 1
    -
  • diff --git a/unit-test/include/class/data/plugin.xml b/unit-test/include/class/data/plugin.xml new file mode 100644 index 000000000..669eb6fc9 --- /dev/null +++ b/unit-test/include/class/data/plugin.xml @@ -0,0 +1,86 @@ + + + + + Skeleton for plugin + + + Example of an XML File for developing a plugin. + + + + SKEL + + + skel + + + index.php + + + Dany De Bontridder + + 9000 + + 9000 + + + EXT + + + skeleton + + 2000 + + + + Second Skeleton for plugin + + + Example of an XML File for developing a plugin. + Second plugin inside + + + PLUGIN_TEST + + + skel + + + index-plugin_test.php + + + Dany De Bontridder + + 8111 + + 9000 + + + EXT + + + skeleton + + 9019 + + \ No newline at end of file diff --git a/unit-test/include/class/extensiontest.php b/unit-test/include/class/extensiontest.php new file mode 100644 index 000000000..e4dbb73f6 --- /dev/null +++ b/unit-test/include/class/extensiontest.php @@ -0,0 +1,139 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Author : Dany De Bontridder danydb@noalyss.eu $(DATE) + */ + +/** + * @file + * @brief noalyss + */ + +use PHPUnit\Framework\TestCase; + +require DIRTEST . '/global.php'; + +/** + * @testdox Class ExtensionTest : used for ... + * @backupGlobals enabled + * @coversDefaultClass + */ +class ExtensionTest extends TestCase +{ + + /** + * @var Fiche + */ + protected $object; + protected $connection; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test method is executed. + */ + protected function setUp(): void + { + + + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test method is executed. + */ + protected function tearDown(): void + { + /** + * example + * if ( ! is_object($this->object->fiche_def)) return; + * include_once DIRTEST.'/global.php'; + * $g_connection=Dossier::connect(); + * $sql=new ArrayObject(); + * $sql->append("delete from fiche_detail where f_id in (select f_id from fiche where fd_id =\$1 )"); + * $sql->append("delete from fiche where f_id not in (select f_id from fiche_detail where \$1=\$1)"); + * $sql->append("delete from jnt_fic_attr where fd_id = \$1 "); + * $sql->append("delete from fiche_def where fd_id = \$1"); + * foreach ($sql as $s) { + * $g_connection->exec_sql($s,[$this->object->fiche_def->id]); + * } + */ + } + + /** + * the setUpBeforeClass() template methods is called before the first test of the test case + * class is run + */ + public static function setUpBeforeClass(): void + { + // include 'global.php'; + } + + /** + * tearDownAfterClass() template methods is calleafter the last test of the test case class is run, + * + */ + static function tearDownAfterClass(): void + { + // include 'global.php'; + } +// +// public function dataExample() +// { +// return array([1], [2], [3]); +// } + + /** + * @testdox check the load of plugin and find the plugin from an access_code + * @covers \Extension::find_extension_code \Extension:read_definition , \Extension::verify + * @backupGlobals on + */ + function testFind_extension_file() + { + global $cn; + require DIRTEST . '/global.php'; + $cn=$g_connection; + $a_extension=\Extension::read_definition(__DIR__."/data/plugin.xml"); + $access_code="EXT/TOOLS/PLUGIN_TEST"; + $extension=\Extension::find_extension_code($a_extension, $access_code); + + $this->assertTrue($extension->me_file=="skel/index-plugin_test.php"); + $this->assertTrue($extension->version==9019, " ne peut retrouver la version"); + $this->assertTrue($extension->noalyss_version==8111," ne peut pas retrouver la version de noalyss"); + } + + /** + * @testdox check the load of plugin and find the plugin from an access_code + * @covers \Extension::find_extension_code \Extension:read_definition\Extension::verify + * @backupGlobals on + */ + function testFind_extension_version() + { + global $cn; + require DIRTEST . '/global.php'; + $cn=$g_connection; + $a_extension=\Extension::read_definition(__DIR__."/data/plugin.xml"); + $access_code="EXT/TOOLS/SKEL"; + $extension=\Extension::find_extension_code($a_extension, $access_code); + + $this->assertTrue($extension->version==2000, " ne peut retrouver la version"); + $this->assertTrue($extension->noalyss_version==9000," ne peut pas retrouver la version de noalyss"); + + } +} \ No newline at end of file