From 70d56be03f2d18eaaa9c8374ef3edda8810bf3a8 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 3 Sep 2025 00:04:05 +0200 Subject: [PATCH] Fix PHPUNIT for PHP8.2 --- include/class/acc_ledger_history.class.php | 2 +- .../class/acc_ledger_history_generic.class.php | 1 - .../class/acc_ledger_history_purchase.class.php | 1 - include/class/acc_ledger_history_sale.class.php | 3 +-- include/class/print_ledger.class.php | 15 ++++++++++++++- .../print_ledger_simple_without_vat.class.php | 4 ++++ unit-test/global.php | 4 ++-- unit-test/include/class/AccountRepositoryTest.php | 1 - .../{acc_compute.Test.php => acc_computeTest.php} | 10 ++++++++++ ...ledger_fin.Test.php => acc_ledger_finTest.php} | 0 ...t.php => acc_ledger_history_financialTest.php} | 0 .../include/class/acc_ledger_purchaseTest.php | 2 +- unit-test/include/class/acc_ledger_saleTest.php | 1 + unit-test/include/class/acc_letter.Test.php | 2 +- ....classTest.php => print_ledger_detailTest.php} | 2 +- ...sTest.php => print_ledger_detail_itemTest.php} | 4 ++-- ...fin.classTest.php => print_ledger_finTest.php} | 8 +++++--- ...sc.classTest.php => print_ledger_miscTest.php} | 4 +++- ....classTest.php => print_ledger_simpleTest.php} | 11 ++++++++--- ...hp => print_ledger_simple_without_vatTest.php} | 10 ++++++++-- 20 files changed, 62 insertions(+), 23 deletions(-) rename unit-test/include/class/{acc_compute.Test.php => acc_computeTest.php} (96%) rename unit-test/include/class/{acc_ledger_fin.Test.php => acc_ledger_finTest.php} (100%) rename unit-test/include/class/{acc_ledger_history_financial.Test.php => acc_ledger_history_financialTest.php} (100%) rename unit-test/include/class/{print_ledger_detail.classTest.php => print_ledger_detailTest.php} (99%) rename unit-test/include/class/{print_ledger_detail_item.classTest.php => print_ledger_detail_itemTest.php} (98%) rename unit-test/include/class/{print_ledger_fin.classTest.php => print_ledger_finTest.php} (93%) rename unit-test/include/class/{print_ledger_misc.classTest.php => print_ledger_miscTest.php} (94%) rename unit-test/include/class/{print_ledger_simple.classTest.php => print_ledger_simpleTest.php} (93%) rename unit-test/include/class/{print_ledger_simple_without_vat.classTest.php => print_ledger_simple_without_vatTest.php} (90%) diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php index 49576bef9..c78186b8b 100644 --- a/include/class/acc_ledger_history.class.php +++ b/include/class/acc_ledger_history.class.php @@ -39,7 +39,7 @@ abstract class Acc_Ledger_History public $db; //!< database connx protected $ledger_type; //! type of ledger VEN , ACH , ODS, FIN protected $filter_operation; //!< to filter paid, unpaid or all operation - + protected $data;//!< array of rows /** * * @param Database $cn diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 6bbabe3b1..f54b5a0ce 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -33,7 +33,6 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { - private $data; //!< array of rows /** * Constructor diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 0dca3160f..f3f593991 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -32,7 +32,6 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History { - private $data;//!< Contains rows from SQL /** * @param mixed $data diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php index 8da3232db..af8ec9a97 100644 --- a/include/class/acc_ledger_history_sale.class.php +++ b/include/class/acc_ledger_history_sale.class.php @@ -32,8 +32,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History { - private $data; //!< Contains rows from SQL - + public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) diff --git a/include/class/print_ledger.class.php b/include/class/print_ledger.class.php index 719dbe74f..eb995b3c6 100644 --- a/include/class/print_ledger.class.php +++ b/include/class/print_ledger.class.php @@ -30,10 +30,23 @@ */ class Print_Ledger extends PDF { - protected $filter_operation; // See Acc_Ledger_History::filter_operation + protected $filter_operation; //!< See Acc_Ledger_History::filter_operation private $ledger ; //!< concerned Ledger private $from ; //! integer parm_periode.p_id , start periode; private $to ; //! integer parm_periode.p_id , end periode; + protected $a_TVA; //!< array of VAT + protected $rap_tva; //!< VAT when page starts + protected $rap_other; //!< VAT when page starts + protected $jrn_type; //!< ledger type (VEN, ODS, FIN,ACH) + protected $previous; //!< previous amount + protected $other_tax_previous; + protected $rap_htva; //!< price without when page starts + protected $rap_tvac; //!< VAT+price when page starts + protected $rap_priv;//!< Private when page starts + protected $rap_nd;//!< ND VAT when page starts + protected $rap_tva_np;//!< NP VAT when page starts + protected $flag_other_tax; //! if other tax + protected $show_col; public function __construct(\Database $p_cn, $orientation, $unit, diff --git a/include/class/print_ledger_simple_without_vat.class.php b/include/class/print_ledger_simple_without_vat.class.php index 844101732..3d96a738f 100644 --- a/include/class/print_ledger_simple_without_vat.class.php +++ b/include/class/print_ledger_simple_without_vat.class.php @@ -32,6 +32,10 @@ class Print_Ledger_Simple_Without_Vat extends Print_Ledger { + protected $tp_priv; + protected $tp_htva; + protected $tp_tvac; + protected $tp_nd; public function __construct ($p_cn,$p_jrn,$p_from,$p_to,$p_filter_operation) { diff --git a/unit-test/global.php b/unit-test/global.php index 2eeeb83aa..c8b0ac956 100644 --- a/unit-test/global.php +++ b/unit-test/global.php @@ -27,8 +27,8 @@ global $g_connection,$g_parameter,$g_user; if (!defined("DOSSIER"))define ("DOSSIER",25); $_REQUEST['gDossier'] = DOSSIER; -$g_connection=new Database(DOSSIER); -$g_parameter = new Noalyss_Parameter_Folder($g_connection); +$g_connection=new \Database(DOSSIER); +$g_parameter = new \Noalyss_Parameter_Folder($g_connection); $_SESSION[SESSION_KEY.'use_name']='unit test'; $_SESSION[SESSION_KEY.'use_first_name']='automatic'; $_SESSION[SESSION_KEY.'g_user']='admin'; diff --git a/unit-test/include/class/AccountRepositoryTest.php b/unit-test/include/class/AccountRepositoryTest.php index e0088d066..10fd4b951 100644 --- a/unit-test/include/class/AccountRepositoryTest.php +++ b/unit-test/include/class/AccountRepositoryTest.php @@ -163,7 +163,6 @@ class AccountRepositoryTest extends TestCase { $db->close(); $this->assertEquals(11, $nb_table, " number of table incorrect $nb_table"); } catch (\Exception $ex) { - $db->close(); echo $ex->getMessage(); echo $ex->getTraceAsString(); $this->assertTrue(false, __CLASS__ . " cannot create DB"); diff --git a/unit-test/include/class/acc_compute.Test.php b/unit-test/include/class/acc_computeTest.php similarity index 96% rename from unit-test/include/class/acc_compute.Test.php rename to unit-test/include/class/acc_computeTest.php index 5065de633..2e7d73090 100644 --- a/unit-test/include/class/acc_compute.Test.php +++ b/unit-test/include/class/acc_computeTest.php @@ -194,6 +194,16 @@ class Acc_ComputeTest extends TestCase public function testCompute() { + print "**********************************************"; + print PHP_EOL; + print "

OUTPUT IN HTML , USE LYNX TO READ

"; + print PHP_EOL; + print " OR REDIRECT TO HTML"; + print PHP_EOL; + print "**********************************************"; + print PHP_EOL; + print "phpunit |lynx -stdin"; + print PHP_EOL; $a=new Acc_Compute(); // Compute some operation to see if the computed amount are // correct diff --git a/unit-test/include/class/acc_ledger_fin.Test.php b/unit-test/include/class/acc_ledger_finTest.php similarity index 100% rename from unit-test/include/class/acc_ledger_fin.Test.php rename to unit-test/include/class/acc_ledger_finTest.php diff --git a/unit-test/include/class/acc_ledger_history_financial.Test.php b/unit-test/include/class/acc_ledger_history_financialTest.php similarity index 100% rename from unit-test/include/class/acc_ledger_history_financial.Test.php rename to unit-test/include/class/acc_ledger_history_financialTest.php diff --git a/unit-test/include/class/acc_ledger_purchaseTest.php b/unit-test/include/class/acc_ledger_purchaseTest.php index d3a7ab25c..7cb77216b 100644 --- a/unit-test/include/class/acc_ledger_purchaseTest.php +++ b/unit-test/include/class/acc_ledger_purchaseTest.php @@ -15,7 +15,7 @@ class Acc_Ledger_PurchaseTest extends TestCase * @var Acc_Ledger_Purchase */ protected $object; - + private $array1; /** * @var array transmitted by _POST */ diff --git a/unit-test/include/class/acc_ledger_saleTest.php b/unit-test/include/class/acc_ledger_saleTest.php index b9eb6756e..328c88771 100644 --- a/unit-test/include/class/acc_ledger_saleTest.php +++ b/unit-test/include/class/acc_ledger_saleTest.php @@ -19,6 +19,7 @@ class Acc_Ledger_SaleTest extends TestCase * @var type */ private $array; + private $array1; /** * Sets up the fixture, for example, opens a network connection. diff --git a/unit-test/include/class/acc_letter.Test.php b/unit-test/include/class/acc_letter.Test.php index 410a5a9b1..2218bd865 100644 --- a/unit-test/include/class/acc_letter.Test.php +++ b/unit-test/include/class/acc_letter.Test.php @@ -39,7 +39,7 @@ class Acc_Letter extends TestCase * @var Fiche */ protected $object; - + private $a_column; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test method is executed. diff --git a/unit-test/include/class/print_ledger_detail.classTest.php b/unit-test/include/class/print_ledger_detailTest.php similarity index 99% rename from unit-test/include/class/print_ledger_detail.classTest.php rename to unit-test/include/class/print_ledger_detailTest.php index 055549b0b..ff845ccfc 100644 --- a/unit-test/include/class/print_ledger_detail.classTest.php +++ b/unit-test/include/class/print_ledger_detailTest.php @@ -35,7 +35,7 @@ class Print_Ledger_DetailTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. diff --git a/unit-test/include/class/print_ledger_detail_item.classTest.php b/unit-test/include/class/print_ledger_detail_itemTest.php similarity index 98% rename from unit-test/include/class/print_ledger_detail_item.classTest.php rename to unit-test/include/class/print_ledger_detail_itemTest.php index 2d3bf7dfd..346088281 100644 --- a/unit-test/include/class/print_ledger_detail_item.classTest.php +++ b/unit-test/include/class/print_ledger_detail_itemTest.php @@ -33,7 +33,7 @@ class Print_Ledger_Detail_ItemTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -63,7 +63,7 @@ class Print_Ledger_Detail_ItemTest extends TestCase // Purchase //------------------------------------------------------------------------------------------------------------- - $ledger_purchase=new Acc_Ledger_Purchase($g_connection,3); + $ledger_purchase=new \Acc_Ledger_Purchase($g_connection,3); // Paid //------------ diff --git a/unit-test/include/class/print_ledger_fin.classTest.php b/unit-test/include/class/print_ledger_finTest.php similarity index 93% rename from unit-test/include/class/print_ledger_fin.classTest.php rename to unit-test/include/class/print_ledger_finTest.php index e51bf1d45..615a9add2 100644 --- a/unit-test/include/class/print_ledger_fin.classTest.php +++ b/unit-test/include/class/print_ledger_finTest.php @@ -33,7 +33,7 @@ class Print_Ledger_FinTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -72,7 +72,7 @@ class Print_Ledger_FinTest extends TestCase $ledger->setTitle(_("Journal"), true); $ledger->export(); $ledger->Output(__DIR__."/file/financial-detail.pdf","F"); - + print "create ".__DIR__."/file/financial-detail.pdf". PHP_EOL; $ledger=\Print_Ledger::factory($g_connection,"L", $ledger_fin, $p_from, $p_to, "paid"); $this->assertTrue($ledger instanceof Print_Ledger_Financial ,"Fin. Detail returns Print_Ledger_Financial"); @@ -83,7 +83,7 @@ class Print_Ledger_FinTest extends TestCase $ledger->setTitle(_("Journal"), true); $ledger->export(); $ledger->Output(__DIR__."/file/financial-listing.pdf","F"); - +print "create ".__DIR__."/file/financial-listing.pdf". PHP_EOL; $ledger=\Print_Ledger::factory($g_connection,"E", $ledger_fin, $p_from, $p_to, "paid"); $this->assertTrue($ledger instanceof Print_Ledger_Detail @@ -95,6 +95,7 @@ class Print_Ledger_FinTest extends TestCase $ledger->setTitle(_("Journal"), true); $ledger->export(); $ledger->Output(__DIR__."/file/financial-extended.pdf","F"); +print "create ".__DIR__."/file/financial-extended.pdf". PHP_EOL; $ledger=\Print_Ledger::factory($g_connection,"A", $ledger_fin, $p_from, $p_to, "paid"); $this->assertTrue($ledger instanceof Print_Ledger_Detail @@ -106,6 +107,7 @@ class Print_Ledger_FinTest extends TestCase $ledger->setTitle(_("Journal"), true); $ledger->export(); $ledger->Output(__DIR__."/file/financial-accounting.pdf","F"); +print "create ".__DIR__."/file/financial-accounting.pdf". PHP_EOL; } } diff --git a/unit-test/include/class/print_ledger_misc.classTest.php b/unit-test/include/class/print_ledger_miscTest.php similarity index 94% rename from unit-test/include/class/print_ledger_misc.classTest.php rename to unit-test/include/class/print_ledger_miscTest.php index 100a978e6..0416d50f1 100644 --- a/unit-test/include/class/print_ledger_misc.classTest.php +++ b/unit-test/include/class/print_ledger_miscTest.php @@ -32,7 +32,7 @@ class Print_Ledger_MiscTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -73,6 +73,7 @@ class Print_Ledger_MiscTest extends TestCase $ledger->setTitle(_("Journal Opérations diverses "), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_detail_misc.pdf", "F"); + print __DIR__."/file/print_ledger_detail_misc.pdf". PHP_EOL; $ledger=\Print_Ledger::factory($g_connection, "L", $ledger_misc, $p_from, $p_to, "all"); $this->assertTrue($ledger instanceof Print_Ledger_Misc @@ -84,6 +85,7 @@ class Print_Ledger_MiscTest extends TestCase $ledger->setTitle(_("Journal Opérations diverses"), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_misc.pdf", "F"); + print __DIR__."/file/print_ledger_misc.pdf". PHP_EOL; } } diff --git a/unit-test/include/class/print_ledger_simple.classTest.php b/unit-test/include/class/print_ledger_simpleTest.php similarity index 93% rename from unit-test/include/class/print_ledger_simple.classTest.php rename to unit-test/include/class/print_ledger_simpleTest.php index 6a0667bb1..817076a61 100644 --- a/unit-test/include/class/print_ledger_simple.classTest.php +++ b/unit-test/include/class/print_ledger_simpleTest.php @@ -33,7 +33,7 @@ class print_ledger_simpleTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -82,6 +82,7 @@ class print_ledger_simpleTest extends TestCase $ledger->setTitle(_("Journal Achat Payé"), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_purchase_paid.pdf", "F"); + $this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_paid.pdf"); // Unpaid //------------ @@ -97,7 +98,7 @@ class print_ledger_simpleTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_purchase_unpaid.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_unpaid.pdf"); - +print __DIR__."/file/print_ledger_simple_purchase_unpaid.pdf".PHP_EOL; // All //------------ $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, $p_from, $p_to, "all"); @@ -112,7 +113,7 @@ class print_ledger_simpleTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_purchase_all.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_all.pdf"); - +print __DIR__."/file/print_ledger_simple_purchase_all.pdf".PHP_EOL; //------------------------------------------------------------------------------------------------------------- // Sale //------------------------------------------------------------------------------------------------------------- @@ -131,6 +132,7 @@ class print_ledger_simpleTest extends TestCase $ledger->setTitle(_("Journal Vente Payé"), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_sale_paid.pdf", "F"); +print __DIR__."/file/print_ledger_simple_sale_paid.pdf".PHP_EOL; // Unpaid //----------------- @@ -146,6 +148,7 @@ class print_ledger_simpleTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_sale_unpaid.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_ledger_simple_sale_unpaid.pdf"); +print __DIR__."/file/print_ledger_simple_sale_unpaid.pdf".PHP_EOL; // All //----------------- @@ -161,6 +164,8 @@ class print_ledger_simpleTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_ledger_simple_sale_all.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_ledger_simple_sale_all.pdf"); +print __DIR__."/file/print_ledger_simple_sale_all.pdf".PHP_EOL; + } } diff --git a/unit-test/include/class/print_ledger_simple_without_vat.classTest.php b/unit-test/include/class/print_ledger_simple_without_vatTest.php similarity index 90% rename from unit-test/include/class/print_ledger_simple_without_vat.classTest.php rename to unit-test/include/class/print_ledger_simple_without_vatTest.php index 18c35d194..517378cf6 100644 --- a/unit-test/include/class/print_ledger_simple_without_vat.classTest.php +++ b/unit-test/include/class/print_ledger_simple_without_vatTest.php @@ -33,7 +33,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase * @var */ protected $object; - + private $from,$to; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -82,7 +82,8 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->setTitle(_("Journal Achat Payé"), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_paid.pdf", "F"); - + $this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_purchase_paid.pdf", "F"); +print __DIR__."/file/print_Ledger_simple_without_vat_purchase_paid.pdf".PHP_EOL; // Unpaid //------------ $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, @@ -96,6 +97,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_unpaid.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_purchase_unpaid.pdf"); +print __DIR__."/file/print_Ledger_simple_without_vat_purchase_unpaid.pdf".PHP_EOL; // All //------------ @@ -110,6 +112,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_all.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_purchase_all.pdf"); +print __DIR__."/file/print_Ledger_simple_without_vat_purchase_all.pdf".PHP_EOL; //------------------------------------------------------------------------------------------------------------- // Sale @@ -128,6 +131,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->setTitle(_("Journal Vente Payé"), true); $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_paid.pdf", "F"); +print __DIR__."/file/print_Ledger_simple_without_vat_sale_paid.pdf".PHP_EOL; // Unpaid //----------------- @@ -142,6 +146,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_unpaid.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_sale_unpaid.pdf"); +print __DIR__."/file/print_Ledger_simple_without_vat_sale_unpaid.pdf".PHP_EOL; // All //----------------- @@ -156,6 +161,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase $ledger->export(); $ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_all.pdf", "F"); $this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_sale_all.pdf"); +print __DIR__."/file/print_Ledger_simple_without_vat_sale_all.pdf".PHP_EOL; } }