diff --git a/unit-test/create-dossier-test.sh b/unit-test/create-dossier-test.sh index 51d1d3607..f838f52ae 100755 --- a/unit-test/create-dossier-test.sh +++ b/unit-test/create-dossier-test.sh @@ -2,6 +2,7 @@ DOSSIER_TEST=rel70dossier25 +dropdb $DOSSIER_TEST createdb $DOSSIER_TEST -pg_restore -Fc --no-owner --no-privilege --verbose -d $DOSSIER_TEST db/dossiertest191112-1806.bin +pg_restore -Fc --no-owner --no-privilege --verbose -d $DOSSIER_TEST db/dossiertest191117-0909.bin diff --git a/unit-test/facility.class.php b/unit-test/facility.class.php index c32a55aff..3f1d0794e 100644 --- a/unit-test/facility.class.php +++ b/unit-test/facility.class.php @@ -61,6 +61,7 @@ EOF; */ static function save_file($p_dir, $p_file, $p_content) { + printf (" saving %s/%s please check this file \n ",$p_dir,$p_file); $hFile=fopen($p_dir."/".$p_file, "w+"); fwrite($hFile, $p_content); fclose($hFile); diff --git a/unit-test/include/class/acc_account_ledger.Test.php b/unit-test/include/class/acc_account_ledger.Test.php index d9c5101f2..c9a79c461 100644 --- a/unit-test/include/class/acc_account_ledger.Test.php +++ b/unit-test/include/class/acc_account_ledger.Test.php @@ -1,8 +1,10 @@ object->get_row(92,103); - $this->assertEquals(count($array),3); + $array=$this->object->get_row(92, 103); + $this->assertEquals(count($array), 3); } /** * @covers Acc_Account_Ledger::get_row_date - * @todo Implement testGet_row_date(). */ public function testGet_row_date() { - $this->object->get_row_date('01.01.2017', '01.02.2017', 0); + global $g_user, $g_connection; + + $accounting=new Acc_Account_Ledger($g_connection, '4511'); + $a_array=$accounting->get_row_date('01.01.2018', '31.12.2018', 0); + $expected=array( + 0=> + array( + 0=> + array( + 'j_id'=>'820', + 'jr_id'=>'317', + 'j_date_fmt'=>'01.01.2018', + 'j_date'=>'2018-01-01', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'8.4000', + 'description'=>'Ecriture d\'ouverture 2018 TVA à payer 21%', + 'jrn_name'=>'Opération Diverses', + 'j_debit'=>'f', + 'jr_internal'=>'O000172', + 'jr_pj_number'=>'ODS44', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'OPE', + 'jr_tech_per'=>'92', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Opération Diverses', + 'jrn_def_code'=>'O01', + 'delta_letter'=>NULL, + ), + 1=> + array( + 'j_id'=>'6', + 'jr_id'=>'2', + 'j_date_fmt'=>'24.02.2018', + 'j_date'=>'2018-02-24', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'8.4000', + 'description'=>'Déplacement', + 'jrn_name'=>'Vente', + 'j_debit'=>'f', + 'jr_internal'=>'V000002', + 'jr_pj_number'=>'VEN2', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'NOR', + 'jr_tech_per'=>'93', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Vente', + 'jrn_def_code'=>'V01', + 'delta_letter'=>NULL, + ), + 2=> + array( + 'j_id'=>'9', + 'jr_id'=>'3', + 'j_date_fmt'=>'24.02.2018', + 'j_date'=>'2018-02-24', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'5.2900', + 'description'=>'Vente de marchandises', + 'jrn_name'=>'Vente', + 'j_debit'=>'f', + 'jr_internal'=>'V000003', + 'jr_pj_number'=>'VEN3', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'NOR', + 'jr_tech_per'=>'93', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Vente', + 'jrn_def_code'=>'V01', + 'delta_letter'=>NULL, + ), + 3=> + array( + 'j_id'=>'13', + 'jr_id'=>'4', + 'j_date_fmt'=>'24.02.2018', + 'j_date'=>'2018-02-24', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'35.7400', + 'description'=>'Vente de marchandises', + 'jrn_name'=>'Vente', + 'j_debit'=>'f', + 'jr_internal'=>'V000004', + 'jr_pj_number'=>'VEN4', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'NOR', + 'jr_tech_per'=>'93', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Vente', + 'jrn_def_code'=>'V01', + 'delta_letter'=>NULL, + ), + 4=> + array( + 'j_id'=>'17', + 'jr_id'=>'5', + 'j_date_fmt'=>'24.04.2018', + 'j_date'=>'2018-04-24', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'35.7400', + 'description'=>'Marchandise et Déplacement', + 'jrn_name'=>'Vente', + 'j_debit'=>'f', + 'jr_internal'=>'V000005', + 'jr_pj_number'=>'VEN5', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'NOR', + 'jr_tech_per'=>'95', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Vente', + 'jrn_def_code'=>'V01', + 'delta_letter'=>NULL, + ), + 5=> + array( + 'j_id'=>'818', + 'jr_id'=>'316', + 'j_date_fmt'=>'12.09.2018', + 'j_date'=>'2018-09-12', + 'j_qcode'=>NULL, + 'deb_montant'=>'0', + 'cred_montant'=>'21.0000', + 'description'=>'Vente en OD TVA à payer 21%', + 'jrn_name'=>'Opération Diverses', + 'j_debit'=>'f', + 'jr_internal'=>'O000171', + 'jr_pj_number'=>'ODS43', + 'letter'=>NULL, + 'pcm_lib'=>'TVA à payer 21%', + 'jr_optype'=>'NOR', + 'jr_tech_per'=>'100', + 'p_exercice'=>'2018', + 'jrn_def_name'=>'Opération Diverses', + 'jrn_def_code'=>'O01', + 'delta_letter'=>NULL, + ), + ), + 1=>'0', + 2=>'114.5700', + ); + $this->assertEquals($expected, $a_array); } + function dataGet_Name() { return array( - array('10','Capital '), - array('01','Poste inconnu') + array('10', 'Capital '), + array('01', 'Poste inconnu') ); } + /** * @covers Acc_Account_Ledger::get_name - * @todo Implement testGet_name(). * @dataProvider dataGet_Name */ - public function testGet_name($id,$result) + public function testGet_name($id, $result) { - $this->object->id=$id; - $this->assertEquals($this->object->get_name(),$result); + $this->object->id=$id; + $this->assertEquals($this->object->get_name(), $result); } /** * @covers Acc_Account_Ledger::do_exist - * @todo Implement testDo_exist(). * @dataProvider dataDo_exist */ public function testDo_exist($p_value, $result) @@ -95,102 +244,79 @@ class Acc_Account_LedgerTest extends TestCase /** * @covers Acc_Account_Ledger::load - * @todo Implement testLoad(). */ public function testLoad() { $this->object->load(); - - } - - /** - * @covers Acc_Account_Ledger::get - * @todo Implement testGet(). - */ - public function testGet() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertTrue($this->object->id==400, "test load"); } /** * @covers Acc_Account_Ledger::get_solde - * @todo Implement testGet_solde(). */ public function testGet_solde() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + global $g_connection; + $accounting=new Acc_Account_Ledger($g_connection, '4511'); + $this->assertEquals($accounting->get_solde(),248.97); } /** * @covers Acc_Account_Ledger::get_solde_detail - * @todo Implement testGet_solde_detail(). */ public function testGet_solde_detail() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + global $g_connection; + $accounting=new Acc_Account_Ledger($g_connection, '4511'); + $expected=array ( + 'debit' => '0', + 'credit' => '248.9700', + 'solde' => 248, + ); + $this->assertEquals($accounting->get_solde_detail(),$expected); } /** * @covers Acc_Account_Ledger::isTVA - * @todo Implement testIsTVA(). */ public function testIsTVA() { $this->object->id="4111"; - $this->assertEquals($this->object->isTVA(),1); + $this->assertEquals($this->object->isTVA(), 1); $this->object->id=10; - $this->assertEquals($this->object->isTVA(),0); - + $this->assertEquals($this->object->isTVA(), 0); } /** * @covers Acc_Account_Ledger::HtmlTable - * @todo Implement testHtmlTable(). */ public function testHtmlTable() { - $this->assertTrue(true,'Ne peut être testé car vue HTML'); + $this->assertTrue(true, 'Ne peut être testé car vue HTML'); } + public function dataGet_amount_side() { - return array ( - array(0,"="), - array(1000,'D'), - array(-1000,'C'), + return array( + array(0, "="), + array(1000, 'D'), + array(-1000, 'C'), ); } - /** - * @covers Acc_Account_Ledger::get_amount_side - * @todo Implement testGet_amount_side(). - * @dataProvider dataGet_amount_side - */ - public function testGet_amount_side($amount,$result) - { - $this->assertEquals($this->object->get_amount_side($amount),$result); - } /** - * @covers Acc_Account_Ledger::HtmlTableHeader - * @todo Implement testHtmlTableHeader(). + * @covers Acc_Account_Ledger::get_amount_side + * @dataProvider dataGet_amount_side */ - public function testHtmlTableHeader() + public function testGet_amount_side($amount, $result) { - // Remove the following lines when you implement this test. - $this->assertTrue(true,'Ne peut être testé car vue HTML'); + $this->assertEquals($this->object->get_amount_side($amount), $result); } + + /** * @covers Acc_Account_Ledger::belong_ledger - * @todo Implement testBelong_ledger(). * @dataProvider DataBelong_ledger */ public function testBelong_ledger($p_jrn, $result) @@ -208,38 +334,33 @@ class Acc_Account_LedgerTest extends TestCase array(4, 0) ); } + public function dataGet_account_ledger() { return array( - array(0,array()), - array(1,array('5*','')), - array(2,array('4*')), - array(3,array('6*')) - + array(0, array()), + array(1, array('5*', '')), + array(2, array('4*')), + array(3, array('6*')) ); } + /** * @covers Acc_Account_Ledger::get_account_ledger - * @todo Implement testGet_account_ledger(). * @dataProvider dataGet_account_ledger */ - public function testGet_account_ledger($p_jrn,$result) + public function testGet_account_ledger($p_jrn, $result) { - echo "ledger $p_jrn"; - $this->assertEquals($this->object->get_account_ledger($p_jrn),$result); - printf ("\n"); + $this->assertEquals($this->object->get_account_ledger($p_jrn), $result); } /** * @covers Acc_Account_Ledger::build_sql_account - * @todo Implement testBuild_sql_account(). * @dataProvider DataBuild_Sql_account */ public function testBuild_sql_account($p_jrn, $result) { - print "\n--------------------\n"; $value=$this->object->build_sql_account($p_jrn); - printf(" ledger %s [%s]", $p_jrn, $value); $this->assertEquals(trim($value), $result); } @@ -275,6 +396,4 @@ class Acc_Account_LedgerTest extends TestCase $this->assertEquals($p_card, $result[0]['f_id']); } - - } diff --git a/unit-test/include/class/acc_balance.Test.php b/unit-test/include/class/acc_balance.Test.php index a649f11cd..0a83f9233 100644 --- a/unit-test/include/class/acc_balance.Test.php +++ b/unit-test/include/class/acc_balance.Test.php @@ -48,10 +48,10 @@ class Acc_BalanceTest extends TestCase $min=$g_connection->get_value("select min(p_id) from parm_periode"); $this->object->jrn=NULL; $array=$this->object->get_row($min,$max); - $this->assertEquals(31,count($array)); + $this->assertEquals(32,count($array)); $this->object->jrn=[2,4]; $array=$this->object->get_row($min,$max); - $this->assertEquals(10,count($array)); + $this->assertEquals(12,count($array)); } diff --git a/unit-test/include/class/acc_ledger.Test.php b/unit-test/include/class/acc_ledger.Test.php index fbc516180..93e8af5bc 100644 --- a/unit-test/include/class/acc_ledger.Test.php +++ b/unit-test/include/class/acc_ledger.Test.php @@ -85,7 +85,7 @@ class Acc_LedgerTest extends TestCase $this->object->id=2; $sPj=$this->object->get_last_pj(2); - $this->assertEquals(40,$sPj); + $this->assertEquals(39,$sPj); $this->object->id=0; try { @@ -564,7 +564,7 @@ class Acc_LedgerTest extends TestCase { global $g_connection; $ledger=new Acc_Ledger($g_connection,4); - $this->assertEquals("3,2,4",$ledger->get_all_fiche_def()); + $this->assertEquals("3,2,4,5",$ledger->get_all_fiche_def()); } /** @@ -574,9 +574,9 @@ class Acc_LedgerTest extends TestCase { $result=[ ["solde"=> 658.25 , "j_poste"=> "4400004", "j_qcode"=> "FOURNI"], - ["solde"=> 490.7700 , "j_poste"=> "4000005", "j_qcode"=> "CLIENT1"], + ["solde"=> 660.17 , "j_poste"=> "4000005", "j_qcode"=> "CLIENT1"], ["solde"=> 87.8400, "j_poste"=> "4112", "j_qcode"=> ""], - ["solde"=>-85.1700 , "j_poste"=> "4511", "j_qcode"=> ""], + ["solde"=>-114.57 , "j_poste"=> "4511", "j_qcode"=> ""], ["solde"=> -1496.3400 , "j_poste"=>"4400005", "j_qcode"=> "FOURNI1"] ]; $get=$this->object->get_saldo_exercice("2018"); @@ -794,7 +794,7 @@ class Acc_LedgerTest extends TestCase public function testSave_new() { global $g_connection; - + $ledger=new Acc_Ledger($g_connection,-1); $array=["p_jrn_name"=>"UNITTEST", "p_ech_lib"=>"", "p_jrn_deb_max_line"=>7, @@ -809,12 +809,14 @@ class Acc_LedgerTest extends TestCase // clean ledger if exists $g_connection->exec_sql("delete from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]); - $this->object->save_new($array); - $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]); + $ledger->save_new($array); + $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1", + [$array['p_jrn_name']]); $this->assertLessThan($jrn_def_id,0); $ledger=new Acc_Ledger($g_connection,$jrn_def_id); $ledger->delete_ledger(); - $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]); + $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1", + [$array['p_jrn_name']]); $this->assertEquals($jrn_def_id,""); } @@ -838,7 +840,8 @@ class Acc_LedgerTest extends TestCase $g_connection->exec_sql("delete from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]); // Recreate it - $this->object->save_new($array); + $ledger=new Acc_Ledger($g_connection,-1); + $ledger->save_new($array); $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]); $this->assertLessThan($jrn_def_id,0); $ledger=new Acc_Ledger($g_connection,$jrn_def_id); diff --git a/unit-test/include/class/acc_ledger_sold.Test.php b/unit-test/include/class/acc_ledger_sold.Test.php index b5745bb00..c700a8829 100644 --- a/unit-test/include/class/acc_ledger_sold.Test.php +++ b/unit-test/include/class/acc_ledger_sold.Test.php @@ -142,8 +142,11 @@ class Acc_Ledger_SoldTest extends TestCase */ public function testInput() { + global $g_connection; $_REQUEST['ac']='VEN'; - $info=$this->object->input($this->array); + $object=new Acc_Ledger_Sold($g_connection, 2); + + $info=$object->input($this->array); if (!is_string($info)) { $this->assertTrue(FALSE); diff --git a/unit-test/include/class/acc_operation.Test.php b/unit-test/include/class/acc_operation.Test.php index c2935c5de..641ecc880 100644 --- a/unit-test/include/class/acc_operation.Test.php +++ b/unit-test/include/class/acc_operation.Test.php @@ -32,17 +32,8 @@ class Acc_OperationTest extends TestCase { } - /** - * @covers Acc_OperationTest::get - * @todo Implement testGet(). - */ - public function testGet() - { - $this->assertEquals(0,0); - } /** *@covers Acc_Operation::seek_group - * @todo Implement seek_group() */ public function testSeek_group() { @@ -52,7 +43,6 @@ class Acc_OperationTest extends TestCase } /** * @covers Acc_Operation::set_id - * @todo Implement testId() * */ public function testSet_id() @@ -67,7 +57,6 @@ class Acc_OperationTest extends TestCase } /** * @covers Acc_Operation::set_paid - * @todo Implement testSet_paid */ function testSet_Paid() { @@ -85,7 +74,6 @@ class Acc_OperationTest extends TestCase } /** * @covers Acc_Operation::get_amount - * @todo Implement testGet_amount */ function testGet_Amount() { diff --git a/unit-test/include/class/anc_grandlivre.Test.php b/unit-test/include/class/anc_grandlivre.Test.php index f43d22673..9a80e9604 100644 --- a/unit-test/include/class/anc_grandlivre.Test.php +++ b/unit-test/include/class/anc_grandlivre.Test.php @@ -19,7 +19,6 @@ class Anc_GrandLivreTest extends TestCase protected function setUp() { global $g_connection; - $this->object=new Anc_GrandLivre($g_connection); } /** diff --git a/unit-test/test-file.sh b/unit-test/test-file.sh index 2381d4089..ef2be52bc 100755 --- a/unit-test/test-file.sh +++ b/unit-test/test-file.sh @@ -42,7 +42,7 @@ if [ ! -z "$FUNCTION" ] ; then else # $PHPUNIT --bootstrap bootstrap.php --whitelist $FILETOTEST --coverage-text=${FILETOTEST%.php}.txt --color $FILETOTEST - $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --whitelist=$CUR_DIR/../include/class --coverage-html=coverage --color $FILETOTEST - #$PHPUNIT --bootstrap bootstrap.php $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST + # $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --whitelist=$CUR_DIR/../include/class --coverage-html=coverage --color $FILETOTEST + $PHPUNIT --bootstrap bootstrap.php $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST fi