diff --git a/include/class/document.class.php b/include/class/document.class.php index 17bb3aba3..ab3f6c1b7 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -251,7 +251,7 @@ class Document { if (mkdir($temp_dir)==false) { - $msg=sprintf("D221."._("Ne peut pas créer le répertoire %s", $temp_dir)); + $msg=sprintf("D221."._("Ne peut pas créer le répertoire %s"), $temp_dir); record_log("D221".$msg); throw new Exception($msg); } diff --git a/unit-test/include/class/Acc_TVATest.php b/unit-test/include/class/Acc_TVATest.php index 5956f4de5..878e4bfe0 100644 --- a/unit-test/include/class/Acc_TVATest.php +++ b/unit-test/include/class/Acc_TVATest.php @@ -23,7 +23,7 @@ */ use PHPUnit\Framework\TestCase; - +use PHPUnit\Framework\Attributes\DataProvider; /** * @backupGlobals enabled * @coversDefaultClass \Acc_Payment @@ -84,7 +84,7 @@ class Acc_TVATest extends TestCase } } - function dataCheck() { + static function dataCheck() { return array( ['abc',true] ,['13A',true] @@ -100,6 +100,7 @@ class Acc_TVATest extends TestCase * @dataProvider dataCheck * @return void */ + #[DataProvider('dataCheck')] function testCheck($tva_code,$result) { $cn=\Dossier::connect(); @@ -117,7 +118,7 @@ class Acc_TVATest extends TestCase $this->assertTrue($result==$check," erreur pour $tva_code "); $this->display_error($tva_rate_mtable); } - function dataBuild() { + static function dataBuild() { return array( ['0A',4] ,['0B',6] @@ -133,6 +134,7 @@ class Acc_TVATest extends TestCase * @dataProvider dataBuild * @return void */ + #[DataProvider('dataBuild')] function testBuild($tva_code,$result) { $cn=\Dossier::connect(); diff --git a/unit-test/include/class/AccountRepositoryTest.php b/unit-test/include/class/AccountRepositoryTest.php index 97c8f32f4..e8763bfb4 100644 --- a/unit-test/include/class/AccountRepositoryTest.php +++ b/unit-test/include/class/AccountRepositoryTest.php @@ -164,7 +164,7 @@ 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/DocumentTest.php b/unit-test/include/class/DocumentTest.php index 0c1d9c74c..657848cdd 100644 --- a/unit-test/include/class/DocumentTest.php +++ b/unit-test/include/class/DocumentTest.php @@ -27,6 +27,8 @@ use PHPUnit\Framework\TestCase; */ require DIRTEST . '/global.php'; +use PHPUnit\Framework\Attributes\DataProvider; + /** * @backupGlobals disabled */ @@ -251,10 +253,10 @@ class DocumentTest extends TestCase { $document->d_id = $d_id; $document->get(); } - return $document; + return $document; } - function dataReplace() { + static function dataReplace() { return array( ["CUST_NAME", "Client 2"], ["SOLDE", 27.29], @@ -270,6 +272,7 @@ class DocumentTest extends TestCase { * @backupGlobals enabled * @dataProvider dataReplace */ + #[DataProvider('dataReplace')] function testReplace2($tag_name, $value) { require "global.php"; static $request = null; @@ -288,7 +291,7 @@ class DocumentTest extends TestCase { $this->assertEquals($name, $value, $tag_name." fails"); } - function dataBalance() + static function dataBalance() { return array( ['CLIENT1',27.29, 4204.14], @@ -301,6 +304,7 @@ class DocumentTest extends TestCase { * @dataProvider dataBalance */ + #[DataProvider('dataBalance')] function testBalance($quickcode,$balance_report,$balance_noreport) { require "global.php"; diff --git a/unit-test/include/class/NoalyssUserTest.php b/unit-test/include/class/NoalyssUserTest.php index 11aa30e80..e9271629c 100644 --- a/unit-test/include/class/NoalyssUserTest.php +++ b/unit-test/include/class/NoalyssUserTest.php @@ -1,6 +1,6 @@ assertEquals($cn->get_value('select count(*) from profile_user where user_name=$1',array('unknown/user')),0); } - public function dataPeriode() + public static function dataPeriode() { return array( [92], @@ -204,6 +204,7 @@ class NoalyssUserTest extends TestCase * @param type $p_id periode id * @dataProvider dataPeriode */ + #[DataProvider('dataPeriode')] public function testPeriode($p_id) { $this->object=new Noalyss_user(Dossier::connect(), USE_ID); diff --git a/unit-test/include/class/acc_accountTest.php b/unit-test/include/class/acc_accountTest.php index d607d5ac2..eaf323509 100644 --- a/unit-test/include/class/acc_accountTest.php +++ b/unit-test/include/class/acc_accountTest.php @@ -1,6 +1,6 @@ object->find_parent(); $this->assertEquals($result,700); } - public function dataFormatAccount() + public static function dataFormatAccount() { return array( ['60élépànç%','60ELEPANC'], @@ -253,6 +253,7 @@ class Acc_AccountTest extends TestCase * @param string $p_result * @dataProvider dataFormatAccount */ + #[DataProvider('dataFormatAccount')] public function testFormatAccount($param,$p_result) { global $g_connection; diff --git a/unit-test/include/class/acc_account_ledgerTest.php b/unit-test/include/class/acc_account_ledgerTest.php index 4997d51e3..561f6c1ab 100644 --- a/unit-test/include/class/acc_account_ledgerTest.php +++ b/unit-test/include/class/acc_account_ledgerTest.php @@ -1,7 +1,7 @@ assertEquals($expected, $a_array); } - function dataGet_Name() + static function dataGet_Name() { return array( array('10', 'Capital '), @@ -301,6 +302,7 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::get_name * @dataProvider dataGet_Name */ + #[DataProvider('dataGet_Name')] public function testGet_name($id, $result) { $this->object->id=$id; @@ -311,13 +313,14 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::do_exist * @dataProvider dataDo_exist */ + #[DataProvider('dataDo_exist')] public function testDo_exist($p_value, $result) { $this->object->id=$p_value; $this->assertEquals($this->object->do_exist(), $result); } - function dataDo_exist() + static function dataDo_exist() { return array( array('400', 1), @@ -380,7 +383,7 @@ class Acc_Account_LedgerTest extends TestCase $this->assertTrue(true, 'Ne peut être testé car vue HTML'); } - public function dataGet_amount_side() + public static function dataGet_amount_side() { return array( array(0, "="), @@ -393,6 +396,7 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::get_amount_side * @dataProvider dataGet_amount_side */ + #[DataProvider('dataGet_amount_side')] public function testGet_amount_side($amount, $result) { $this->assertEquals($this->object->get_amount_side($amount), $result); @@ -404,12 +408,13 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::belong_ledger * @dataProvider DataBelong_ledger */ + #[DataProvider('DataBelong_ledger')] public function testBelong_ledger($p_jrn, $result) { $this->assertEquals($this->object->belong_ledger($p_jrn), $result); } - function DataBelong_ledger() + static function DataBelong_ledger() { return array( array(-1, 0), @@ -420,7 +425,7 @@ class Acc_Account_LedgerTest extends TestCase ); } - public function dataGet_account_ledger() + public static function dataGet_account_ledger() { return array( array(0, array()), @@ -435,6 +440,7 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::get_account_ledger * @dataProvider dataGet_account_ledger */ + #[DataProvider('dataGet_account_ledger')] public function testGet_account_ledger($p_jrn, $result) { $this->assertEquals($this->object->get_account_ledger($p_jrn), $result); @@ -444,13 +450,14 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::build_sql_account * @dataProvider DataBuild_Sql_account */ + #[DataProvider('DataBuild_Sql_account')] public function testBuild_sql_account($p_jrn, $result) { $value=$this->object->build_sql_account($p_jrn); $this->assertEquals(trim($value), $result); } - public function DataBuild_Sql_account() + public static function DataBuild_Sql_account() { return array( array(0, ""), @@ -461,7 +468,7 @@ class Acc_Account_LedgerTest extends TestCase ); } - function dataFind_Card() + static function dataFind_Card() { return array( array('6191', '27'), @@ -475,13 +482,14 @@ class Acc_Account_LedgerTest extends TestCase * @todo Implement testFind_card(). * @dataProvider dataFind_Card() */ + #[DataProvider('dataFind_Card')] public function testFind_card($p_value, $p_card) { $this->object->id=$p_value; $result=$this->object->find_card(); $this->assertEquals($p_card, $result[0]['f_id']); } - public function dataGet_used_accounting() + public static function dataGet_used_accounting() { $array=array( ["01.01.2020","31.12.2020",5,7,4] @@ -500,6 +508,7 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::get_used_accounting * @dataProvider dataGet_used_accounting */ + #[DataProvider('dataGet_used_accounting')] public function testGet_UsedAcccounting($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting) { $a_result=Acc_Account_Ledger::get_used_accounting(from_date:$from_date @@ -514,7 +523,7 @@ class Acc_Account_LedgerTest extends TestCase /** * @return array : idx [ $accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred] */ - public function dataRowNotLettered() + public static function dataRowNotLettered() { $array=array( ['4400005','01.01.2019','31.12.2019',9,0,954.10] @@ -527,6 +536,7 @@ class Acc_Account_LedgerTest extends TestCase * @covers Acc_Account_Ledger::get_row_date * @dataProvider dataRowNotLettered */ + #[DataProvider('dataRowNotLettered')] public function testGetRowDataNotLetted($accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred) { global $g_connection; diff --git a/unit-test/include/class/acc_computeTest.php b/unit-test/include/class/acc_computeTest.php index 5065de633..be82ba4cc 100644 --- a/unit-test/include/class/acc_computeTest.php +++ b/unit-test/include/class/acc_computeTest.php @@ -1,6 +1,6 @@ expectException(Exception::class); + $this->expectException(\Exception::class); $array=[ "p_jrn"=>"15", "p_jrn_deb_max_line"=>5, diff --git a/unit-test/include/class/acc_ledger_history_generic.Test.php b/unit-test/include/class/acc_ledger_history_genericTest.php similarity index 100% rename from unit-test/include/class/acc_ledger_history_generic.Test.php rename to unit-test/include/class/acc_ledger_history_genericTest.php diff --git a/unit-test/include/class/acc_ledger_history_purchase.Test.php b/unit-test/include/class/acc_ledger_history_purchase.Test.php deleted file mode 100644 index 5781dff72..000000000 --- a/unit-test/include/class/acc_ledger_history_purchase.Test.php +++ /dev/null @@ -1,123 +0,0 @@ - - -/** - * @file - * @brief concerne acc_ledger_history_purchaseTest.class - */ -class Acc_Ledger_History_PurchaseTest extends TestCase -{ - - /** - * @var - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp():void - { - include DIRTEST.'/global.php'; - global $g_connection; - $this->object=new Acc_Ledger_History_Purchase($g_connection, [3], 92, 131, 'L'); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown():void - { - - } - private function save_file($p_name,$content) - { - $hFile=fopen(__DIR__."/file/".$p_name,"w+"); - fwrite($hFile, $content); - fclose($hFile); - } - //@covers Acc_Ledger_History_Financial::get_row , Acc_Ledger_History_Financial::get_data - function testGet_Row() - { - $this->object->get_row(); - $this->assertEquals(16,count($this->object->get_data()),"Acc_Ledger_History_Purchase->get_data"); - - } - //@covers Acc_Ledger_History_Financial::export_oneline_html - function testExport_Oneline_Html() - { - //- Listing - $name="acc_ledger_history_purchase_export_listing.html"; - $this->object->set_m_mode("L"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Extended - $name="acc_ledger_history_purchase_export_extended.html"; - $this->object->set_m_mode("E"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Detail - $name="acc_ledger_history_purchase_export_detail.html"; - $this->object->set_m_mode("D"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Accounting - $name="acc_ledger_history_purchase_export_accounting.html"; - $this->object->set_m_mode("D"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - } - /** - * @covers Acc_Ledger_History::get_ledger_type - */ - - function testGet_Ledger_type() - { - $this->assertEquals($this->object->get_ledger_type(),'ACH'); - } -} diff --git a/unit-test/include/class/acc_ledger_history_sale.Test.php b/unit-test/include/class/acc_ledger_history_sale.Test.php deleted file mode 100644 index 7a8bb1f61..000000000 --- a/unit-test/include/class/acc_ledger_history_sale.Test.php +++ /dev/null @@ -1,121 +0,0 @@ - - -/** - * @file - * @brief concerne Acc_Ledger_History_SaleTest.class - */ -class Acc_Ledger_History_SaleTest extends TestCase -{ - - /** - * @var - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp():void - { - include 'global.php'; - global $g_connection; - $this->object=new Acc_Ledger_History_Sale($g_connection,[2],92,131,'L'); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown():void - { - - } - function testGet_row() - { - $this->object->get_row(); - $this->assertEquals(6,count($this->object->get_data()),"Acc_Ledger_History_Sale->get_row"); - } - private function save_file($p_name,$content) - { - $hFile=fopen(__DIR__."/file/".$p_name,"w+"); - fwrite($hFile, $content); - fclose($hFile); - } - //@covers Acc_Ledger_History_Sale::export_oneline_html - function testExport_Oneline_Html() - { - //- Listing - $name="acc_ledger_history_sale_export_listing.html"; - $this->object->set_m_mode("L"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Extended - $name="acc_ledger_history_sale_export_extended.html"; - $this->object->set_m_mode("E"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Detail - $name="acc_ledger_history_sale_export_detail.html"; - $this->object->set_m_mode("D"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - - //- Accounting - $name="acc_ledger_history_sale_export_accounting.html"; - $this->object->set_m_mode("D"); - ob_start(); - echo \Noalyss\Facility::page_start(); - $this->object->export_html(); - $content=ob_get_contents(); - ob_end_clean(); - $this->save_file($name, $content); - $this->assertFileExists(__DIR__."/file/".$name); - } - /** - * @covers Acc_Ledger_History::get_ledger_type - */ - - function testGet_Ledger_type() - { - $this->assertEquals($this->object->get_ledger_type(),'VEN'); - } -} diff --git a/unit-test/include/class/acc_ledger_info.Test.php b/unit-test/include/class/acc_ledger_infoTest.php similarity index 100% rename from unit-test/include/class/acc_ledger_info.Test.php rename to unit-test/include/class/acc_ledger_infoTest.php diff --git a/unit-test/include/class/acc_ledger_purchaseTest.php b/unit-test/include/class/acc_ledger_purchaseTest.php index c41f20bf3..2bb4f3a43 100644 --- a/unit-test/include/class/acc_ledger_purchaseTest.php +++ b/unit-test/include/class/acc_ledger_purchaseTest.php @@ -1,7 +1,7 @@ exec_sql("update jrnx set j_montant =$2 where j_id=$1 ",[$p_jrnx_id,$restore]); } - public function dataDateLimit() + public static function dataDateLimit() { return array( [100,'01.01.2018','31.12.2018'], @@ -211,6 +200,7 @@ class Acc_LetterTest extends TestCase * @param type $p_id * @dataProvider dataDateLimit */ + #[DataProvider('dataDateLimit')] public function testDateLimitComputed($p_periode_id,$p_first_day,$p_last_day) { global $g_connection; @@ -239,6 +229,7 @@ class Acc_LetterTest extends TestCase * @param type $p_id * @dataProvider dataDateLimit */ + #[DataProvider('dataDateLimit')] public function testDateLimitGiven($p_periode_id,$p_first_day,$p_last_day) { global $g_connection; diff --git a/unit-test/include/class/acc_operationTest.php b/unit-test/include/class/acc_operationTest.php index e2c16dee6..423eaa19a 100644 --- a/unit-test/include/class/acc_operationTest.php +++ b/unit-test/include/class/acc_operationTest.php @@ -1,5 +1,6 @@ exec_sql("delete from plan_analytique where pa_id>1"); } - public function datasqlStmt() + public static function datasqlStmt() { return array([1,"Group 1",1], [2,"Group 2",1], @@ -98,6 +98,7 @@ class Anc_GroupTest extends TestCase * @param type $p_param * @covers */ + #[DataProvider('datasqlStmt')] public function test_sqlStmt($p_ga_id,$pga_description,$ppa_id) { global $g_connection; diff --git a/unit-test/include/class/anc_key.Test.php b/unit-test/include/class/anc_keyTest.php similarity index 100% rename from unit-test/include/class/anc_key.Test.php rename to unit-test/include/class/anc_keyTest.php diff --git a/unit-test/include/class/anc_key_sql.Test.php b/unit-test/include/class/anc_key_sqlTest.php similarity index 94% rename from unit-test/include/class/anc_key_sql.Test.php rename to unit-test/include/class/anc_key_sqlTest.php index aaf1b7a8b..51be4658c 100644 --- a/unit-test/include/class/anc_key_sql.Test.php +++ b/unit-test/include/class/anc_key_sqlTest.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase; /** * Generated by PHPUnit_SkeletonGenerator on 2014-11-08 at 14:23:52. */ -class Anc_Key_Detail_SQLTest extends TestCase +class Anc_Key_SQLTest extends TestCase { /** diff --git a/unit-test/include/class/ficheTest.php b/unit-test/include/class/ficheTest.php index fe257b33e..31cca57cd 100644 --- a/unit-test/include/class/ficheTest.php +++ b/unit-test/include/class/ficheTest.php @@ -1,7 +1,7 @@ assertEquals($nb_fiche, $nb_fiche_after, 'card not removed'); } - public function dataEmptyQuickCode() + public static function dataEmptyQuickCode() { return array( array("none", ""), @@ -328,6 +323,7 @@ class FicheTest extends TestCase * @testdox testInsertEmptyQuickCode Test if it is possible to insert an empty quickcode * @dataProvider dataEmptyQuickCode */ + #[DataProvider('dataEmptyQuickCode')] public function testInsertEmptyQuickCode($name, $quick_code) { //insert @@ -338,7 +334,7 @@ class FicheTest extends TestCase $fiche->remove(); } - function dataUpdateQuickCode() + static function dataUpdateQuickCode() { return array( array('a+z+1-5', 'AZ1-5'), @@ -358,6 +354,7 @@ class FicheTest extends TestCase * @testdox testUpdateEmptyQuickCode Test if it is possible to update an empty quickcode * @dataProvider dataUpdateQuickCode */ + #[DataProvider('dataUpdateQuickCode')] public function testUpdateEmptyQuickCode($name, $quick_code) { $aCardId=[]; @@ -439,7 +436,7 @@ where } } - function dataFormat_QuickCode() + static function dataFormat_QuickCode() { return array( array('a+z+1-5','AZ1-5'), @@ -458,12 +455,13 @@ where * @testdox test comptaproc.format_quickcode * @dataProvider dataFormat_Quickcode */ + #[DataProvider('dataFormat_Quickcode')] public function testFormat_QuickCode($p_qcode,$p_result) { $this->assertEquals($p_result,$this->g_connection->get_value( "select comptaproc.format_quickcode($1)", [$p_result]),'quickcode is not transformed correctly'); } - function dataInsertName() + static function dataInsertName() { return array( ['',"Nom vide"], @@ -475,6 +473,7 @@ where * @testdox Test if it is possible to insert an empty name * @dataProvider dataInsertName */ + #[DataProvider('dataInsertName')] public function testInsertName($p_name,$p_result) { @@ -490,6 +489,7 @@ where * @testdox Test if it is possible to insert or update a empty name * @dataProvider dataInsertName */ + #[DataProvider('dataInsertName')] public function testUpdateName($p_name,$p_result) { @@ -613,7 +613,7 @@ where $this->assertEquals($i,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created'); } } - public function dataAccount() + public static function dataAccount() { return array( ['600002','600002'], @@ -626,6 +626,7 @@ where * @testdox testAccountInsert Set of the accounting while inserting, numeric with automatic * @dataProvider dataAccount */ + #[DataProvider('dataAccount')] public function testAccountInsert($p_value,$p_expected) { $fiche=$this->build_fiche(2, 'PHPUNIT.ACCOUNT.INSERT'); @@ -697,6 +698,7 @@ where * @testdox testAccountUpdate et of the accounting while updating * @dataProvider dataAccount */ + #[DataProvider('dataAccount')] public function testAccountUpdate($p_value,$p_expected) { $this->g_connection->exec_sql("update public.parameter set pr_value = $1 where pr_id=$2", diff --git a/unit-test/include/class/followup_detail.Test.php b/unit-test/include/class/followup_detailTest.php similarity index 98% rename from unit-test/include/class/followup_detail.Test.php rename to unit-test/include/class/followup_detailTest.php index 3463984ab..588dfe4d3 100644 --- a/unit-test/include/class/followup_detail.Test.php +++ b/unit-test/include/class/followup_detailTest.php @@ -34,7 +34,7 @@ use PHPUnit\Framework\TestCase; */ #[\AllowDynamicProperties] -class Follow_Up_DetailTest extends TestCase +class FollowUp_DetailTest extends TestCase { /** diff --git a/unit-test/include/class/impressTest.class.php b/unit-test/include/class/impressTest.class.php index a42966805..17b374239 100644 --- a/unit-test/include/class/impressTest.class.php +++ b/unit-test/include/class/impressTest.class.php @@ -1,7 +1,7 @@ exec_sql("delete from operation_analytique where oa_id > 48 and oa_id < 57"); - $sql="INSERT INTO operation_analytique + $sql="INSERT INTO operation_analytique (oa_id,po_id,oa_amount,oa_description,oa_debit,j_id,oa_date,oa_row,oa_jrnx_id_source,oa_positive,f_id) VALUES - (49,3,90.0000,'',true,18,'2018-02-24',0,NULL,'Y',NULL), - (50,4,93.0000,'',true,18,'2018-02-24',1,NULL,'Y',NULL), - (51,3,10.0000,'Déplacement',false,4,'2018-02-24',0,NULL,'Y',NULL), - (52,1,30.0000,'Déplacement',false,4,'2018-02-24',1,NULL,'Y',NULL), - (53,3,25.0000,'Vente de marchandises',false,7,'2018-02-24',0,NULL,'Y',NULL), - (54,3,91.0000,'Eau',true,371,'2018-04-24',0,NULL,'Y',NULL), - (55,3,80.0000,'Eau',true,371,'2018-04-24',1,NULL,'Y',NULL)"; + (49,3,90.0000,'',true,18,'2018-02-24',0,NULL,'Y',NULL), + (50,4,93.0000,'',true,18,'2018-02-24',1,NULL,'Y',NULL), + (51,3,10.0000,'Déplacement',false,4,'2018-02-24',0,NULL,'Y',NULL), + (52,1,30.0000,'Déplacement',false,4,'2018-02-24',1,NULL,'Y',NULL), + (53,3,25.0000,'Vente de marchandises',false,7,'2018-02-24',0,NULL,'Y',NULL), + (54,3,91.0000,'Eau',true,371,'2018-04-24',0,NULL,'Y',NULL), + (55,3,80.0000,'Eau',true,371,'2018-04-24',1,NULL,'Y',NULL)"; $g_connection->exec_sql($sql); - } /** * @@ -154,6 +145,7 @@ class ImpressTest extends TestCase * @covers Impress::parse_formula * @dataProvider getData_compute_amount */ + #[DataProvider('getData_compute_amount')] function test_compute_amount($p_accounting,$p_amount) { global $g_connection; @@ -224,7 +216,6 @@ class ImpressTest extends TestCase function test_parse_formula() { global $g_connection,$g_user; - $this->setData(); $a_formula=array( 0=>array("sum 70% (credit is negative)", "[70%-s]",-456.80), 1=>array("sum 70% (debit is negative)", "0-round([70%-s],2)",456.80), diff --git a/unit-test/include/class/periodeTest.php b/unit-test/include/class/periodeTest.php index 41a92fbc9..830bbc519 100644 --- a/unit-test/include/class/periodeTest.php +++ b/unit-test/include/class/periodeTest.php @@ -27,7 +27,7 @@ * @brief */ use PHPUnit\Framework\TestCase; - +use PHPUnit\Framework\Attributes\DataProvider; /** * @backupGlobals enabled */ @@ -77,7 +77,7 @@ class PeriodeTest extends TestCase // include 'global.php'; } - public function dataInsert() + public static function dataInsert() { return array( [ '01.01.2023' , '31.01.2023','2020','2020.2023','NOK'], @@ -95,6 +95,7 @@ class PeriodeTest extends TestCase * @param type $p_param * @covers */ + #[DataProvider('dataInsert')] public function testInsert($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status) { global $g_connection; @@ -126,7 +127,7 @@ class PeriodeTest extends TestCase } $g_connection->exec_sql("delete from parm_periode where p_id > 144"); } - public function dataUpdate() + public static function dataUpdate() { return array( [ '01.01.2023' , '31.01.2023','2023','2020.2023','OK'], @@ -141,6 +142,7 @@ class PeriodeTest extends TestCase * * */ + #[DataProvider('dataUpdate')] public function testUpdate($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status) { @@ -183,7 +185,7 @@ class PeriodeTest extends TestCase } - public function dataUpdateException() + public static function dataUpdateException() { return array( [ '01.01.2023' , '31.01.2023','2020','2020.2023','NOK'], @@ -199,6 +201,7 @@ class PeriodeTest extends TestCase * * */ + #[DataProvider('dataUpdateException')] public function testUpdateException($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status) { 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 100% rename from unit-test/include/class/print_ledger_detail_item.classTest.php rename to unit-test/include/class/print_ledger_detail_itemTest.php diff --git a/unit-test/include/class/print_ledger_fin.classTest.php b/unit-test/include/class/print_ledger_finTest.php similarity index 100% rename from unit-test/include/class/print_ledger_fin.classTest.php rename to unit-test/include/class/print_ledger_finTest.php diff --git a/unit-test/include/class/print_ledger_misc.classTest.php b/unit-test/include/class/print_ledger_miscTest.php similarity index 100% rename from unit-test/include/class/print_ledger_misc.classTest.php rename to unit-test/include/class/print_ledger_miscTest.php diff --git a/unit-test/include/class/print_ledger_simple.classTest.php b/unit-test/include/class/print_ledger_simpleTest.php similarity index 100% rename from unit-test/include/class/print_ledger_simple.classTest.php rename to unit-test/include/class/print_ledger_simpleTest.php 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 100% 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 diff --git a/unit-test/include/class/todo_list.Test.php b/unit-test/include/class/todo_listTest.php similarity index 100% rename from unit-test/include/class/todo_list.Test.php rename to unit-test/include/class/todo_listTest.php diff --git a/unit-test/include/lib/ac_commonTest.php b/unit-test/include/lib/ac_commonTest.php index 91f2ff39c..97e3ff611 100644 --- a/unit-test/include/lib/ac_commonTest.php +++ b/unit-test/include/lib/ac_commonTest.php @@ -1,6 +1,7 @@ assertEquals(isDate($p_date),$return,"Test $p_date"); } - function dataCompareDate () + static function dataCompareDate ():array { return array( ['01.01.1992','05.02.2001',-1], @@ -238,6 +240,7 @@ class Ac_CommonTest extends TestCase * @testDox test cmpDate * @dataProvider dataCompareDate */ + #[DataProvider('dataCompareDate')] function testCompareDate($p_date,$p_date_2,$p_result) { $cmp=cmpDate($p_date,$p_date_2); @@ -266,7 +269,7 @@ class Ac_CommonTest extends TestCase $this->assertEquals("<&",h("<&")); $this->assertEquals(0,h("0")); } - function dataFormat_Date() + static function dataFormat_Date() { return array( ["01.05.2000","DD.MM.YYYY","DD.MM.YY",'01.05.00'], @@ -287,6 +290,7 @@ class Ac_CommonTest extends TestCase * @throws Exception * @dataProvider dataFormat_date */ + #[DataProvider('dataFormat_date')] function testFormatDate($p_date,$p_from,$p_to,$p_result) { $this->assertEquals($p_result,format_date($p_date,$p_from,$p_to)); @@ -305,7 +309,7 @@ class Ac_CommonTest extends TestCase $this->assertEquals("l''éléphant",Database::escape_string("l'éléphant")); $this->assertEquals("l\''éléphant",Database::escape_string("l\'éléphant")); } - function dataNoalyss_trim() + static function dataNoalyss_trim() { return array(["0","0"], [" 0 1 1 1 ","0 1 1 1"], @@ -320,11 +324,12 @@ class Ac_CommonTest extends TestCase * @return void * @dataProvider dataNoalyss_trim */ + #[DataProvider('dataNoalyss_trim')] function testNoalyss_trim($param,$result) { $this->assertEquals($result,noalyss_trim($param)); } - function dataNoalyss_replace() { + static function dataNoalyss_replace() { return array(["0","/","0A0A","/A/A"], ["A","*","0A0A","0*0*"], ["0","/",null,""], @@ -336,11 +341,12 @@ class Ac_CommonTest extends TestCase * @brief Comptability PHP 8.1 , null is not consider as an empty string * @dataProvider dataNoalyss_replace */ + #[DataProvider('dataNoalyss_replace')] function testNoalyss_replace($search,$replace,$string,$expected) { $this->assertEquals($expected,noalyss_str_replace($search,$replace,$string)); } - function dataNoalyss_bcsub() { + static function dataNoalyss_bcsub() { return array( [1,2,-1], [0,2,-2], @@ -353,11 +359,12 @@ class Ac_CommonTest extends TestCase * @brief Comptability PHP 8.1 , null is not consider as an empty string * @dataProvider dataNoalyss_bcsub */ + #[DataProvider('dataNoalyss_bcsub')] function testNoalyss_bcsub($numbera,$numberb,$expected) { $this->assertEquals($expected,noalyss_bcsub($numbera,$numberb)); } - function dataNoalyss_strip_tags() { + static function dataNoalyss_strip_tags() { return array( [null,""], ["",""], @@ -370,6 +377,7 @@ class Ac_CommonTest extends TestCase * @brief Comptability PHP 8.1 , null is not consider as an empty string * @dataProvider dataNoalyss_strip_tags */ + #[DataProvider('dataNoalyss_strip_tags')] function testNoalyss_strip_tags($string,$expected) { $this->assertEquals($expected,noalyss_strip_tags($string)); @@ -429,7 +437,7 @@ EOF; * supply data for user password * @return array[$password, $weakness] 0 means strong password */ - public function dataCheck_password_strength() + public static function dataCheck_password_strength() { return array( ["AAAAAAA",5] @@ -446,6 +454,7 @@ EOF; * @testDoc test the check_password_strength function * @dataProvider dataCheck_password_strength() */ + #[DataProvider('dataCheck_password_strength')] public function testCheck_password_strength($p_password,$p_cnt) {