[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 07/27: TEST : add new files
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 07/27: TEST : add new files |
Date: |
Sat, 2 Nov 2019 18:12:13 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit d42fa25d740167d36a258c42e6b13e2977c39b97
Author: Dany De Bontridder <address@hidden>
Date: Sat Nov 2 00:56:45 2019 +0100
TEST : add new files
---
unit-test/bootstrap.php.example | 2 +-
unit-test/create-dossier-test.sh | 5 +-
unit-test/document/fr_be/bnb.form | 3 +
unit-test/document/fr_be/bnb.rtf | 0
unit-test/global.php | 6 +-
.../include/class/acc_account_ledgerTest.class.php | 7 +-
unit-test/include/class/acc_balanceTest.class.php | 2 +-
unit-test/include/class/acc_bilanTest.class.php | 92 +--
unit-test/include/class/acc_ledgerTest.class.php | 731 ++++++++++-----------
.../include/class/acc_ledger_finTest.class.php | 49 +-
.../acc_ledger_history_purchaseTest.class.php | 61 ++
.../class/acc_ledger_history_saleTest.class.php | 60 ++
.../include/class/acc_ledger_infoTest.class.php | 85 +++
.../class/acc_ledger_purchaseTest.class.php | 12 +-
unit-test/jrn.csv | 18 +
unit-test/test-file.sh | 41 +-
16 files changed, 674 insertions(+), 500 deletions(-)
diff --git a/unit-test/bootstrap.php.example b/unit-test/bootstrap.php.example
index b598df3..11d4906 100644
--- a/unit-test/bootstrap.php.example
+++ b/unit-test/bootstrap.php.example
@@ -24,8 +24,8 @@ require_once '../include/constant.php';
define ("ALLOWED",1);
-define ("DOSSIER",26);
+ini_set("xdebug.overload_var_dump",0);
/**
* Class to include,
diff --git a/unit-test/create-dossier-test.sh b/unit-test/create-dossier-test.sh
index 0526bd6..47884ba 100755
--- a/unit-test/create-dossier-test.sh
+++ b/unit-test/create-dossier-test.sh
@@ -1,6 +1,7 @@
#!/bin/bash
-DOSSIER_TEST=dossier48
+DOSSIER_TEST=rel70dossier25
-pg_restore -Fc --no-owner --no-privilege --verbose -d $DOSSIER_TEST
db/dossiertest.bin
+createdb $DOSSIER_TEST
+pg_restore -Fc --no-owner --no-privilege --verbose -d $DOSSIER_TEST
db/dossiertest191101-2109.bin
diff --git a/unit-test/document/fr_be/bnb.form
b/unit-test/document/fr_be/bnb.form
new file mode 100644
index 0000000..25ad085
--- /dev/null
+++ b/unit-test/document/fr_be/bnb.form
@@ -0,0 +1,3 @@
+$C70=round([70%],2)
+$C60=round([60%],2)
+
diff --git a/unit-test/document/fr_be/bnb.rtf b/unit-test/document/fr_be/bnb.rtf
new file mode 100644
index 0000000..e69de29
diff --git a/unit-test/global.php b/unit-test/global.php
index b37fd1c..1296166 100644
--- a/unit-test/global.php
+++ b/unit-test/global.php
@@ -24,10 +24,12 @@
* Global variables
*/
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);
-$_SESSION['g_user']='phpcompta';
-$_SESSION['g_pass']='dany';
+$_SESSION['g_user']='admin';
+$_SESSION['g_pass']='phpcompta';
$_SESSION['g_pagesize']='50';
$g_user=new User($g_connection);
diff --git a/unit-test/include/class/acc_account_ledgerTest.class.php
b/unit-test/include/class/acc_account_ledgerTest.class.php
index 630b487..9882b32 100644
--- a/unit-test/include/class/acc_account_ledgerTest.class.php
+++ b/unit-test/include/class/acc_account_ledgerTest.class.php
@@ -42,7 +42,8 @@ class Acc_Account_LedgerTest extends TestCase
*/
public function testGet_row()
{
- $this->object->get_row(215,235);
+ $array=$this->object->get_row(92,103);
+ $this->assertEquals(count($array),3);
}
/**
@@ -256,8 +257,8 @@ class Acc_Account_LedgerTest extends TestCase
function dataFind_Card()
{
return array(
- array('6191', '22'),
- array('6192', '23'),
+ array('6191', '27'),
+ array('6192', '28'),
array('4400004', '25')
);
}
diff --git a/unit-test/include/class/acc_balanceTest.class.php
b/unit-test/include/class/acc_balanceTest.class.php
index b599945..915242d 100644
--- a/unit-test/include/class/acc_balanceTest.class.php
+++ b/unit-test/include/class/acc_balanceTest.class.php
@@ -51,7 +51,7 @@ class Acc_BalanceTest extends TestCase
$this->assertEquals(14,count($array));
$this->object->jrn=[2,4];
$array=$this->object->get_row($min,$max);
- $this->assertEquals(8,count($array));
+ $this->assertEquals(7,count($array));
}
diff --git a/unit-test/include/class/acc_bilanTest.class.php
b/unit-test/include/class/acc_bilanTest.class.php
index 85352dd..c72baa6 100644
--- a/unit-test/include/class/acc_bilanTest.class.php
+++ b/unit-test/include/class/acc_bilanTest.class.php
@@ -55,12 +55,12 @@ class Acc_BilanTest extends TestCase
*/
public function testVerify()
{
- ob_start();
- $this->object->verify();
- $r=ob_get_contents();
- ob_end_clean();
-
- $this->assertStringStartsWith('<h3>',$r);
+ ob_start();
+ $this->object->verify();
+ $r=ob_get_contents();
+ ob_end_clean();
+
+ $this->assertStringStartsWith('<h3>',$r);
}
/**
@@ -69,10 +69,13 @@ class Acc_BilanTest extends TestCase
*/
public function testGet_request_get()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $_GET['b_id']=111;
+ $_GET['from_periode']=95;
+ $_GET['to_periode']=100;
+ $this->object->get_request_get();
+ $this->assertEquals($this->object->b_id,111);
+ $this->assertEquals($this->object->from,95);
+ $this->assertEquals($this->object->to,100);
}
/**
@@ -81,46 +84,65 @@ class Acc_BilanTest extends TestCase
*/
public function testLoad()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ $this->object->b_id=1;
+ $this->object->load();
+ $this->assertEquals($this->object->b_type,'rtf');
+
$this->assertEquals($this->object->b_file_form,'document/fr_be/bnb.form');
}
/**
* @covers Acc_Bilan::file_open_form
- * @todo Implement testFile_open_form().
+ *
*/
public function testFile_open_form()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->b_id=1;
+ $this->object->load();
+ try {
+ $file=$this->object->file_open_form();
+ $this->assertTrue(TRUE);
+ } catch(Exception $e) {
+ echo $e->getTraceAsString();
+ $this->assertTrue(FALSE);
+ }
}
/**
* @covers Acc_Bilan::file_open_template
- * @todo Implement testFile_open_template().
+ *
*/
public function testFile_open_template()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->b_id=1;
+ $this->object->load();
+ try {
+ $file=$this->object->file_open_template();
+ $this->assertTrue(TRUE);
+ } catch(Exception $e) {
+ echo $e->getTraceAsString();
+ $this->assertTrue(FALSE);
+ }
}
/**
* @covers Acc_Bilan::compute_formula
- * @todo Implement testCompute_formula().
*/
public function testCompute_formula()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->b_id=1;
+ $hFile=fopen("document/fr_be/bnb.form",'r');
+
+ $this->object->from=92;
+ $this->object->to=103;
+
+ $this->object->compute_formula($hFile);
+
+ $this->assertTrue(isset($this->object->C70));
+ $this->assertTrue(isset($this->object->C60));
+ $this->assertEquals($this->object->C70,445.6);
+ $this->assertEquals($this->object->C60,0);
+
}
/**
@@ -171,16 +193,6 @@ class Acc_BilanTest extends TestCase
);
}
- /**
- * @covers Acc_Bilan::test_me
- * @todo Implement testTest_me().
- */
- public function testTest_me()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+
}
diff --git a/unit-test/include/class/acc_ledgerTest.class.php
b/unit-test/include/class/acc_ledgerTest.class.php
index 8429f8c..1e50b48 100644
--- a/unit-test/include/class/acc_ledgerTest.class.php
+++ b/unit-test/include/class/acc_ledgerTest.class.php
@@ -71,8 +71,7 @@ class Acc_LedgerTest extends TestCase
$this->object->id=2;
$sPj=$this->object->get_last_pj(2);
- print_r("get_last_pj $sPj");
- $this->assertEquals(5,$sPj);
+ $this->assertEquals(9,$sPj);
}
@@ -99,22 +98,13 @@ class Acc_LedgerTest extends TestCase
$this->assertEquals('ACH',$type);
}
- /**
- * @covers Acc_Ledger::delete
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- global $g_connection;
- $jr_id=$g_connection->get_value("select max(jr_id) from jrn");
- $this->object->jr_id=$jr_id;
- $this->object->delete();
- $count=$g_connection->get_value("select count(*) from jrn where
jr_id=$1",[$jr_id]);
- $this->assertEquals($count,0);
- }
+
public function delete_ledger()
{
global $g_connection;
+ // 0. clean
+ $g_connection->exec_sql("delete from jrn_def where
jrn_def_name=$1",["UNITTEST"]);
+
// a . create a ledger and delete it
$array=["p_jrn_def_name"=>"UNITTEST","p_ech_lib"=>"","p_jrn_deb_max_line"=>7,'p_jrn_type'=>'ODS','jrn_def_pj_pref'=>'TT/','min_row'=>5,'p_description'=>'LEDGER
UNIT TEST','jrn_def_negative_amount'=>0,'jrn_def_negative_warning'=>'Warning'];
$this->object->save_new($array);
@@ -141,6 +131,10 @@ class Acc_LedgerTest extends TestCase
$this->assertEquals($ok,1);
$cnt=$g_connection->get_value("select count(*) from jrn_def where
jrn_def_id=$1",[$ledger_id]);
$this->assertEquals($cnt,1);
+
+ // 0. clean
+ $g_connection->exec_sql("delete from jrn_def where
jrn_def_name=$1",["UNITTEST"]);
+
}
/**
* @covers Acc_Ledger::display_warning
@@ -164,10 +158,8 @@ class Acc_LedgerTest extends TestCase
$this->assertFalse(empty($this->object->jr_id),"not found jr_id ");
$this->object->id=$g_connection->get_value("select jr_def_id from jrn
where jr_id=$1",[$this->object->jr_id]);
- $this->assertGreaterThan($this->object->id,"0","found id
".$this->object->id);
+ $this->assertLessThan($this->object->id,"0","found id
".$this->object->id);
$this->assertFalse(empty($this->object->id),"not found id ");
- print_r("jr_id = ".$this->object->jr_id);
- print_r("id = ".$this->object->id);
$date=$g_connection->get_value ("select
to_char(max(p_start),'DD.MM.YYYY') from parm_periode where p_closed='f'");
$this->object->reverse($date,'unit test'.$date);
$check=$g_connection->get_value("select jr_id from jrn where
jr_comment=$1",["unit test".$date]);
@@ -213,7 +205,7 @@ class Acc_LedgerTest extends TestCase
{
$this->object->id=2;
$r=$this->object->guess_pj();
- $this->assertEquals("VEN6",$r);
+ $this->assertEquals("VEN10",$r);
}
/**
@@ -230,17 +222,6 @@ class Acc_LedgerTest extends TestCase
}
/**
- * @covers Acc_Ledger::GetDefLine
- * @todo Implement testGetDefLine().
- */
- public function testGetDefLine()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
- /**
* @covers Acc_Ledger::display_negative_warning
*/
public function testDisplay_negative_warning()
@@ -278,10 +259,14 @@ class Acc_LedgerTest extends TestCase
*/
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;
+ $ledger=new Acc_Ledger($g_connection,2);
+ $max=$g_connection->get_value("select max(p_id) from parm_periode");
+ $min=$g_connection->get_value("select min(p_id) from parm_periode");
+ $solde=$ledger->get_solde($min,$max);
+ $this->assertEquals($solde[0],490.77);
+ $this->assertEquals($solde[1],490.77);
+
}
/**
@@ -290,22 +275,20 @@ class Acc_LedgerTest extends TestCase
*/
public function testSelect_ledger()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $select_available=$this->object->select_ledger();
+ $this->assertEquals(4,count($select_available->value));
}
-
/**
* @covers Acc_Ledger::get_fiche_def
* @todo Implement testGet_fiche_def().
*/
public function testGet_fiche_def()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,0);
+ $this->assertEmpty($ledger->get_fiche_def());
+ $ledger=new Acc_Ledger($g_connection,2);
+ $this->assertEquals(2,count($ledger->get_fiche_def()));
}
/**
@@ -314,10 +297,11 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_class_def()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,0);
+ $this->assertEmpty($ledger->get_class_def());
+ $ledger=new Acc_Ledger($g_connection,2);
+ $this->assertEquals(1,count($ledger->get_class_def()));
}
/**
@@ -326,10 +310,50 @@ class Acc_LedgerTest extends TestCase
*/
public function testConfirm()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $array=[
+ array("ac"=>"COMPTA/MENUODS/ODS"),
+ "pa_id"=>array(2),
+ "e_date"=>"17.11.2018",
+ "desc"=>"",
+ "period"=>102,
+ "e_pj"=>"ODS1",
+ "e_pj_suggest"=>"ODS1",
+ "mt"=>1572640802.992,
+ "e_comm"=>"",
+ "jrn_type"=>"ODS",
+ "p_jrn"=>4,
+ "nb_item"=>3,
+ "jrn_concerned"=>"",
+ "gDossier"=>25,
+ "qc_0"=>"",
+ "poste0"=>601,
+ "ld0"=>"Achats de fournitures",
+ "ck0"=>"",
+ "amount0"=>100,
+ "op"=>array(0),
+ "amount_t0"=>100,
+ "hplan"=>array(array(-1)),
+ "val"=>array(array(100)),
+ "poste1"=>"4511",
+ "ld1"=>"TVA à payer 21%",
+ "ck1"=>"",
+ "qc_1"=>"",
+ "amount1"=>21,
+ "qc_2"=>"FOURNI2",
+ "ld2"=>"fournisseur 3",
+ "amount2"=>121,
+ "opd_name"=>"",
+ "od_description"=>"",
+ "reverse_date"=>"",
+ "ext_label"=>"",
+ "jr_optype"=>"NOR",
+ "save"=>"Confirmer"
+ ];
+ $this->object->set_ledger_id(4);
+ $this->object->with_concerned=FALSE;
+ $ret=$this->object->confirm($array);
+ $this->assertContains('td class="num">121,00<INPUT TYPE="hidden"
id="amount2" NAME="amount2" VALUE="121"></td></tr><tr class="highlight"><td
></td><td >Totaux</td><td class="num">121.00</td><td
class="num">121.00</td></tr></table><input type="button" class="button"
value="verifie Imputation Analytique" onClick="verify_ca(\'\');">',$ret);
+
}
/**
@@ -338,10 +362,15 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_min_row()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $a_ledger=$g_connection->get_array("select jrn_def_id,jrn_deb_max_line
from jrn_def");
+ $nb_ledger=(empty($a_ledger))?0:count($a_ledger);
+ $this->assertGreaterThan (0,$nb_ledger);
+ for ($i=0;$i<$nb_ledger;$i++) {
+ $ledger=new Acc_Ledger($g_connection,$a_ledger[$i]['jrn_def_id']);
+ $cnt=$ledger->get_min_row();
+ $this->assertEquals($a_ledger[$i]['jrn_deb_max_line'],$cnt);
+ }
}
/**
@@ -350,10 +379,29 @@ class Acc_LedgerTest extends TestCase
*/
public function testInput()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ try {
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ put_global([["key"=>"ac","value"=>"ODS"]]);
+ $str=$ledger->input(null,0);
+
//---------------------------------------------------------------------------
+ // Save it first , and test after
+ // $file=fopen(__DIR__."/file/acc_ledgerTest.testInput.txt","w+");
+ // fwrite($file, $str);
+ // fclose($file);
+
//---------------------------------------------------------------------------
+ $str_fileresult=tempnam("/tmp","acc_ledger_input.txt");
+ $fileresult=fopen($str_fileresult,"w+");
+ fwrite($fileresult,$str);
+// fclose($fileresult);
+
+ $this->assertContains('
onChange="format_number(this);checkTotalDirect()" ',
+ $str);
+ } catch (Exception $ex) {
+ $this->assertTrue(False);
+ throw $ex;
+ }
}
/**
@@ -362,22 +410,43 @@ class Acc_LedgerTest extends TestCase
*/
public function testIs_closed()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ $this->assertEquals(1,$ledger->is_closed(99));
+ $this->assertEquals(0,$ledger->is_closed(101));
}
/**
* @covers Acc_Ledger::verify
* @todo Implement testVerify().
*/
- public function testVerify()
+ public function testVerify_Ledger()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ $array=[
+ "p_jrn"=>"15",
+ "p_jrn_deb_max_line"=>5,
+ "p_jrn_name"=>"New ledger",
+ "p_jrn_type"=>"ODS"
+ ];
+ // Must success
+ try {
+ $ledger->verify_ledger($array);
+ $this->assertTrue(TRUE);
+ } catch (Exception $ex) {
+ var_dump($ex->getMessage());
+ var_dump($ex->getTraceAsString());
+ }
+
+ // Must fail
+ $a_ledger["p_jrn"]="a";
+ try {
+ $ledger->verify_ledger($array);
+ $this->assertTrue(FALSE);
+ } catch (Exception $ex) {
+ $this->assertTrue(TRUE);
+ }
}
/**
@@ -386,34 +455,60 @@ class Acc_LedgerTest extends TestCase
*/
public function testCompute_internal_code()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->set_ledger_id(4);
+ $str=$this->object->compute_internal_code(10);
+ $this->assertFalse(empty($str));
}
/**
- * @covers Acc_Ledger::save
- * @todo Implement testSave().
+ * @covers Acc_Ledger::save Acc_Ledger::delete
*/
public function testSave()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::get_request
- * @todo Implement testGet_request().
- */
- public function testGet_request()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $array=[
+ "pa_id"=>array(2),
+ "e_date"=>"01.09.2018",
+ "desc"=>"test",
+ "period"=>100,
+ "e_pj"=>"ODS1",
+ "e_pj_suggest"=>"ODS1",
+ "mt"=>1572642748.22,
+ "e_comm"=>"test",
+ "jrn_type"=>"ODS",
+ "p_jrn"=>4,
+ "nb_item"=>5,
+ "jrn_concerned"=>"",
+ "gDossier"=>25,
+ "poste0"=>601,
+ "ld0"=>"Achats de fournitures",
+ "ck0"=>"",
+ "amount0"=>100,
+ "op"=>Array(0),
+ "amount_t0"=>100,
+ "hplan"=>array( array(-1)),
+ "val"=>array(array("0"=>array("0"=>100))),
+ "poste1"=>"4511",
+ "ld1"=>"TVA à payer 21%",
+ "amount1"=>100,
+ "opd_name"=>"",
+ "od_description"=>"",
+ "reverse_date"=>"",
+ "ext_label"=>"",
+ "jr_optype"=>"NOR"
+ ];
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ $g_connection->exec_sql("delete from jrn where
jr_mt=$1",[$array["mt"]]);
+ $cnt=$g_connection->get_value("select count(*) from jrn where
jr_mt=$1",[$array['mt']]);
+ $this->assertEquals(0,$cnt);
+ $ledger->save($array);
+ $cnt=$g_connection->get_value("select count(*) from jrn where
jr_mt=$1",[$array['mt']]);
+ $this->assertEquals(1,$cnt);
+
+ $ledger->delete();
+ $cnt=$g_connection->get_value("select count(*) from jrn where
jr_mt=$1",[$array['mt']]);
+ $this->assertEquals(0,$cnt);
+
}
/**
@@ -422,10 +517,9 @@ class Acc_LedgerTest extends TestCase
*/
public function testNext_number()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $this->assertEquals(2,Acc_Ledger::next_number($g_connection, "ODS"));
+
}
/**
@@ -434,46 +528,10 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_first()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::update_paid
- * @todo Implement testUpdate_paid().
- */
- public function testUpdate_paid()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::update_internal_code
- * @todo Implement testUpdate_internal_code().
- */
- public function testUpdate_internal_code()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::get_default_card
- * @todo Implement testGet_default_card().
- */
- public function testGet_default_card()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ $first_ledger=$ledger->get_first("ODS");
+ $this->assertEquals(4,$first_ledger["jrn_def_id"]);
}
/**
@@ -482,10 +540,9 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_all_fiche_def()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $ledger=new Acc_Ledger($g_connection,4);
+ $this->assertEquals("3,2,4",$ledger->get_all_fiche_def());
}
/**
@@ -494,34 +551,31 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_saldo_exercice()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::check_strict
- * @todo Implement testCheck_strict().
- */
- public function testCheck_strict()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::check_periode
- * @todo Implement testCheck_periode().
- */
- public function testCheck_periode()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $result=[
+ ["solde"=> 658.2500 , "j_poste"=> "4400004", "j_qcode"=>
"FOURNI"],
+ ["solde"=> 490.7700 , "j_poste"=> "4000005", "j_qcode"=>
"CLIENT1"],
+ ["solde"=> 21.9600, "j_poste"=> "4112", "j_qcode"=> ""],
+ ["solde"=>-85.1700 , "j_poste"=> "4511", "j_qcode"=> ""],
+ ["solde"=> -863.2100 , "j_poste"=>"4400005", "j_qcode"=> "FOURNI1"]
+ ];
+ $get=$this->object->get_saldo_exercice("2018");
+ $nb_get=count($get);
+ $nb_result=count($result);
+ $ix=0;
+ for ($i=0;$i<$nb_get;$i++)
+ {
+ for ($e=0;$e<$nb_result;$e++) {
+ if (
+ $result[$e]["j_poste"] == $get[$i]["j_poste"] &&
+ $result[$e]["j_qcode"] == $get[$i]["j_qcode"]
+ )
+ {
+
$this->assertEquals($result[$e]["solde"],$get[$i]["solde"]);
+ $ix++;
+ }
+ }
+ }
+ $this->assertEquals(5,$ix);
}
/**
@@ -530,10 +584,9 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_last_date()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->set_ledger_id(2);
+ $last_date=$this->object->get_last_date();
+ $this->assertEquals("24.04.2018",$last_date);
}
/**
@@ -542,179 +595,11 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_id()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::create_document
- * @todo Implement testCreate_document().
- */
- public function testCreate_document()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::check_payment
- * @todo Implement testCheck_payment().
- */
- public function testCheck_payment()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::inc_seq_pj
- * @todo Implement testInc_seq_pj().
- */
- public function testInc_seq_pj()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::search_form
- * @todo Implement testSearch_form().
- */
- public function testSearch_form()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::build_search_sql
- * @todo Implement testBuild_search_sql().
- */
- public function testBuild_search_sql()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->assertEquals(3,$this->object->get_id("V000003"));
}
- /**
- * @covers Acc_Ledger::display_search_form
- * @todo Implement testDisplay_search_form().
- */
- public function testDisplay_search_form()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+
- /**
- * @covers Acc_Ledger::get_last
- * @todo Implement testGet_last().
- */
- public function testGet_last()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::search_group
- * @todo Implement testSearch_group().
- */
- public function testSearch_group()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::get_operation
- * @todo Implement testGet_operation().
- */
- public function testGet_operation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::existing_vat
- * @todo Implement testExisting_vat().
- */
- public function testExisting_vat()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::get_other_amount
- * @todo Implement testGet_other_amount().
- */
- public function testGet_other_amount()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::vat_operation
- * @todo Implement testVat_operation().
- */
- public function testVat_operation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::previous_amount
- * @todo Implement testPrevious_amount().
- */
- public function testPrevious_amount()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::test_me
- * @todo Implement testTest_me().
- */
- public function testTest_me()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
/**
* @covers Acc_Ledger::array_cat
@@ -762,54 +647,98 @@ class Acc_LedgerTest extends TestCase
$this->assertGreaterThan(0,$this->object->get_tiers_id("VEN",$jr_id));
}
- /**
- * @covers Acc_Ledger::listing
- * @todo Implement testListing().
- */
- public function testListing()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::display_ledger
- * @todo Implement testDisplay_ledger().
- */
- public function testDisplay_ledger()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
+
/**
* @covers Acc_Ledger::verify_ledger
* @todo Implement testVerify_ledger().
*/
- public function testVerify_ledger()
+ public function testVerify_Operation()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
+ global $g_connection;
+ $array = [ "p_jrn" => 4,
+ "p_jrn_predef" => 4,
+ "action" => "use_opd",
+ "jrn_type" => "ODS",
+ "e_date" => "17.11.2018",
+ "e_pj" => "ODS1",
+ "e_pj_suggest" => "ODS1",
+ "desc" => "",
+ "nb_item" => 5,
+ "qc_0" => "",
+ "poste0" => "601",
+ "ld0" => "Achats de fournitures",
+ "amount0" => 100,
+ "ck0" => "",
+ "qc_1" => "",
+ "poste1" => "4511",
+ "ld1" => "TVA à payer 21%",
+ "amount1" => 21,
+ "ck1" => "",
+ "qc_2" => "FOURNI2",
+ "poste2" => "",
+ "ld2" => "fournisseur 3",
+ "amount2" => 121,
+ "qc_3" => "",
+ "poste3" => "",
+ "ld3" => "",
+ "amount3" => "",
+ "qc_4" => "",
+ "poste4" => "",
+ "ld4" => "",
+ "amount4" =>"",
+ "jrn_concerned" => "",
+ "summary" => "Sauvez"
+ ];
+ $ledger=new Acc_Ledger($g_connection,4);
+
+ // This test must succeed
+ try {
+ $ledger->verify_operation($array);
+ $this->assertTrue(TRUE);
+ } catch(Exception $e)
+ {
+ var_dump($e->getMessage());
+ var_dump($e->getTraceAsString());
+ $this->assertTrue(FALSE);
+ throw $e;
+ }
+
+ // wrong date must fail
+
+ $wrong_array=$array;
+ $wrong_array["e_date"]="aaa";
+ try {
+ $ledger->verify_operation($wrong_array);
+ $this->assertTrue(FALSE);
+ } catch(Exception $e)
+ {
+ $this->assertEquals(2,$e->getCode());
+ }
+
+ // periode closed must fail
+ $wrong_array=$array;
+ $wrong_array["e_date"]="01.01.2110";
+ try {
+ $ledger->verify_operation($wrong_array);
+ $this->assertTrue(FALSE);
+ } catch(Exception $e)
+ {
+ $this->assertEquals(2,$e->getCode());
+ }
+ // periode closed must fail
+ $wrong_array=$array;
+ $wrong_array["e_date"]="01.07.2018";
+ try {
+ $ledger->verify_operation($wrong_array);
+ $this->assertTrue(FALSE);
+ } catch(Exception $e)
+ {
+ $this->assertEquals(6,$e->getCode());
+ }
- /**
- * @covers Acc_Ledger::update
- * @todo Implement testUpdate().
- */
- public function testUpdate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
}
+
/**
* @covers Acc_Ledger::input_paid
*/
@@ -826,10 +755,19 @@ class Acc_LedgerTest extends TestCase
*/
public function testInput_new()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ put_global([["key"=>"ac","value"=>"ODS"]]);
+// ob_start();
+//
+// $this->object->set_ledger_id(4);
+// $this->object->input_new();
+// $result=ob_get_contents();
+// $file=fopen(__DIR__."/file/acc_ledger_input_new.txt","w+");
+// fwrite($file,$result);
+// fclose($file);*/
+ $this->expectOutputRegex('!<tr><TD> <INPUT TYPE="CHECKBOX" VALUE="3"
NAME="FIN_FICHEDEB\[\]" CHECKED>Banque<\/TD><\/TR><tr><TD> <INPUT
TYPE="CHECKBOX" VALUE="2" NAME="FIN_FICHEDEB\[\]"
CHECKED>Client<\/TD><\/TR><tr><TD> <INPUT TYPE="CHECKBOX" VALUE="4"
NAME="FIN_FICHEDEB\[\]" CHECKED>Fournisseur<\/TD><\/TR><tr><TD> <INPUT
TYPE="CHECKBOX" VALUE="1" NAME="FIN_FICHEDEB\[\]"
unchecked>Marchandises<\/TD><\/TR><tr><TD> <INPUT TYPE="CHECKBOX" VALUE="5"
NAME="FIN_FICHEDEB\[\]" unchecked> [...]
+');
+ $this->object->set_ledger_id(4);
+ $this->object->input_new();
}
/**
@@ -850,10 +788,12 @@ class Acc_LedgerTest extends TestCase
'negative_amount'=>0,
'negative_warning'=>'Warning'];
-
+ // 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']]);
- $this->assertGreaterThan($jrn_def_id,0);
+ $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']]);
@@ -877,10 +817,13 @@ class Acc_LedgerTest extends TestCase
'p_description'=>'LEDGER UNIT TEST',
'negative_amount'=>0,
'negative_warning'=>'Warning'];
-
+ // clean ledger if exists
+ $g_connection->exec_sql("delete from jrn_def where
jrn_def_name=$1",[$array['p_jrn_name']]);
+
+ // Recreate it
$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']]);
- $this->assertGreaterThan($jrn_def_id,0);
+ $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']]);
@@ -940,16 +883,4 @@ class Acc_LedgerTest extends TestCase
$this->assertTrue(is_array($this->object->get_customer_late()));
}
- /**
- * @covers Acc_Ledger::convert_from_follow
- * @todo Implement testConvert_from_follow().
- */
- public function testConvert_from_follow()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
}
diff --git a/unit-test/include/class/acc_ledger_finTest.class.php
b/unit-test/include/class/acc_ledger_finTest.class.php
index eb4f506..1d6fe32 100644
--- a/unit-test/include/class/acc_ledger_finTest.class.php
+++ b/unit-test/include/class/acc_ledger_finTest.class.php
@@ -32,16 +32,7 @@ class Acc_Ledger_FinTest extends TestCase
}
- /**
- * @covers Acc_Ledger_Fin::verify
- * @todo Implement testVerify().
- * @expectedException Exception
- */
- public function testVerify()
- {
- $this->object->verify(null);
- }
/**
* @covers Acc_Ledger_Fin::input
@@ -49,10 +40,8 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testInput()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ // we must compare the output to a file we save previously
+
}
/**
@@ -61,10 +50,8 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testConfirm()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ // we must compare the output to a file we save previously
+
}
/**
@@ -73,10 +60,7 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testInsert()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
}
/**
@@ -85,10 +69,6 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testShow_ledger()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
}
/**
@@ -99,8 +79,8 @@ class Acc_Ledger_FinTest extends TestCase
{
$name=$this->object->get_bank_name();
var_export($name);
- if (strpos($name, NOTFOUND)!=0)
- $this->assertTrue(FALSE);
+ if (strpos($name, NOTFOUND)!=0) $this->assertTrue(FALSE);
+ $this->assertTrue(TRUE);
}
/**
@@ -109,7 +89,7 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testGet_bank()
{
- $this->assertEquals(9, $this->object->get_bank());
+ $this->assertEquals(30, $this->object->get_bank());
}
/**
@@ -118,10 +98,6 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testNumb_operation()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
}
/**
@@ -130,10 +106,11 @@ class Acc_Ledger_FinTest extends TestCase
*/
public function testInsert_quant_fin()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ }
+ public function testVerify_operation()
+ {
+
}
}
diff --git a/unit-test/include/class/acc_ledger_history_purchaseTest.class.php
b/unit-test/include/class/acc_ledger_history_purchaseTest.class.php
new file mode 100644
index 0000000..d9a88d5
--- /dev/null
+++ b/unit-test/include/class/acc_ledger_history_purchaseTest.class.php
@@ -0,0 +1,61 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta 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.
+ *
+ * PhpCompta 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 PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @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()
+ {
+ include '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()
+ {
+
+ }
+ function testGet_Row()
+ {
+ $this->object->get_row();
+ $this->assertSame(count($this->object->get_data()),2);
+
+ }
+}
diff --git a/unit-test/include/class/acc_ledger_history_saleTest.class.php
b/unit-test/include/class/acc_ledger_history_saleTest.class.php
new file mode 100644
index 0000000..6197445
--- /dev/null
+++ b/unit-test/include/class/acc_ledger_history_saleTest.class.php
@@ -0,0 +1,60 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta 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.
+ *
+ * PhpCompta 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 PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @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()
+ {
+ 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()
+ {
+
+ }
+ function testGet_row()
+ {
+ $this->object->get_row();
+ $this->assertSame(count($this->object->get_data()),4);
+ }
+}
diff --git a/unit-test/include/class/acc_ledger_infoTest.class.php
b/unit-test/include/class/acc_ledger_infoTest.class.php
new file mode 100644
index 0000000..a918598
--- /dev/null
+++ b/unit-test/include/class/acc_ledger_infoTest.class.php
@@ -0,0 +1,85 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta 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.
+ *
+ * PhpCompta 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 PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne acc_ledger_infoTest.class
+ */
+class Acc_Ledger_InfoTest 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()
+ {
+ include 'global.php';
+ global $g_connection;
+ $this->object=new Acc_Ledger_Info($g_connection);
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+ function test_insertBonCommande()
+ {
+ global $g_connection;
+ $this->object->jr_id=3;
+ $this->object->id_type='BON_COMMANDE';
+ $this->object->ji_value='BON';
+
+ $cnt=$g_connection->get_array("select * from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+ $this->assertSame(count($cnt),0);
+ $this->object->insert();
+ $cnt=$g_connection->get_array("select * from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+ $this->assertSame(count($cnt),1);
+ $g_connection->exec_sql("delete from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+
+ }
+ function test_insertOther()
+ {
+ global $g_connection;
+ $this->object->set_jrn_id(7);
+ $this->object->set_type('OTHER');
+ $this->object->set_value('Autre test');
+
+ $cnt=$g_connection->get_array("select * from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+ $this->assertSame(count($cnt),0);
+ $this->object->insert();
+ $cnt=$g_connection->get_array("select * from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+ $this->assertSame(count($cnt),1);
+ $g_connection->exec_sql("delete from jrn_info where
jr_id=$1",[$this->object->jr_id]);
+ }
+
+}
diff --git a/unit-test/include/class/acc_ledger_purchaseTest.class.php
b/unit-test/include/class/acc_ledger_purchaseTest.class.php
index ee8fabb..543e88a 100644
--- a/unit-test/include/class/acc_ledger_purchaseTest.class.php
+++ b/unit-test/include/class/acc_ledger_purchaseTest.class.php
@@ -39,7 +39,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
*/
public function testVerify()
{
- $this->object->verify(array());
+ $this->object->verify_operation(array());
}
/**
@@ -90,16 +90,6 @@ class Acc_Ledger_PurchaseTest extends TestCase
);
}
- /**
- * @covers Acc_Ledger_Purchase::show_unpaid
- * @todo Implement testShow_unpaid().
- */
- public function testShow_unpaid()
- {
- // OBSOLETE : function must be removed in the next code cleaning
- // $str_html=$this->object->show_unpaid();
-
- }
/**
* @covers Acc_Ledger_Purchase::get_detail_purchase
diff --git a/unit-test/jrn.csv b/unit-test/jrn.csv
new file mode 100644
index 0000000..0c000f5
--- /dev/null
+++ b/unit-test/jrn.csv
@@ -0,0 +1,18 @@
+jr_id,jr_def_id,jr_montant,jr_comment,jr_date,jr_grpt_id,jr_internal,jr_tech_date,jr_tech_per,jrn_ech,jr_ech,jr_rapt,jr_valid,jr_opid,jr_c_opid,jr_pj,jr_pj_name,jr_pj_type,jr_pj_number,jr_mt,jr_date_paid
+"1","3","146.4100","","2014-08-28","3","A000001","2014-08-28
17:53:24.755317","99",,,,"t",,,,,,"ACH1","1409241201.1562",
+"3","3","202.0700","","2014-08-28","5","A000003","2014-09-13
15:34:19.25992","99",,,,"t",,,,,,"ACH3","1410615199.5593",
+"4","3","202.0700","","2014-08-28","6","A000004","2014-09-13
16:54:52.202829","99",,,,"t",,,,,,"ACH4","1410619351.7227",
+"5","3","202.0700","","2014-08-28","7","A000005","2014-09-13
16:55:41.921773","99",,,,"t",,,,,,"ACH6","1410620127.6059",
+"6","3","55.6600","","2014-08-28","8","A000006","2014-09-14
16:19:50.015866","99",,,,"t",,,,,,"ACH8","1410704378.3556",
+"7","3","55.6600","","2014-08-28","9","A000007","2014-09-14
16:20:21.53739","99",,,,"t",,,,,,"ACH9","1410704406.2889",
+"8","3","55.6600","","2014-08-28","10","A000008","2014-09-14
16:25:25.223477","99",,,,"t",,,,,,"ACH11","1410704712.7114",
+"9","3","55.6600","","2014-08-28","11","A000009","2014-09-14
16:29:37.365348","99",,,,"t",,,,,,"ACH13","1410704965.6442",
+"10","3","55.6600","","2014-08-28","13","A00000B","2014-09-14
16:33:20.104077","99",,,,"t",,,,,,"ACH15","1410705109.1476",
+"2","3","146.4100","","2014-08-28","4","A000002","2014-09-12
22:27:14.991746","99",,,,"t",,,,,,"ACH2","1410553517.1469",
+"11","3","55.6600","","2014-08-28","16","A00000E","2014-09-14
16:36:46.455321","99",,,,"t",,,,,,"ACH17","1410705241.3828",
+"12","3","146.4100","","2014-08-28","17","A00000F","2014-09-15
00:05:06.829017","99",,,,"t",,,,,,"ACH18","1410732301.987",
+"13","3","146.4100","","2014-08-28","18","A000010","2014-09-16
20:56:35.623517","99",,,,"t",,,,,,"ACH19","1410893782.0265",
+"14","3","55.6600","","2014-08-28","19","A000011","2014-09-17
20:27:46.676824","99",,,,"t",,,,,,"ACH20","1410977970.5959",
+"16","2","186.4900","","2014-09-02","21","V000013","2014-11-02
20:23:15.250815","100",,,,"t",,,,,,"VEN2","1414956188.5832",
+"15","2","1697.0100","","2014-09-01","20","V000012","2014-11-02
20:22:50.431444","100",,,,"t",,,,,,"VEN1","1414956163.4927","2014-11-02"
+"17","1","1697.1000"," compte : Banque a
Dupont","2014-11-02","22","F000014","2014-11-02
20:25:19.529644","102",,,,"t",,,,,,"FIN1","1414956317.8088",
diff --git a/unit-test/test-file.sh b/unit-test/test-file.sh
index 0f906ce..8b2e879 100755
--- a/unit-test/test-file.sh
+++ b/unit-test/test-file.sh
@@ -1,9 +1,42 @@
#!/bin/bash
-
+help(){
+ echo "$0 -f filename [-i function ]"
+ echo " -f filename , file to test"
+ echo " -i function , optional filter to a function"
+}
PHPUNIT=./phpunit
-if [ ! -f "$1" ] ; then
- echo "File $1 not found"
+FILETOTEST=""
+FUNCTION=""
+while getopts "f:i:" opt; do
+ case $opt in
+ f)
+ FILETOTEST=$OPTARG
+ ;;
+ i)
+ FUNCTION=$OPTARG
+ ;;
+ *)
+ help
+ exit 1
+ esac
+done
+
+if [ -z "$FILETOTEST" ] ;then
+ help
+ echo "-f is mandatory"
+ exit 2
+fi
+
+if [ ! -f "$FILETOTEST" ] ; then
+ echo "File $FILETOTEST not found"
exit 1
fi
-$PHPUNIT --bootstrap bootstrap.php --color $1
+if [ ! -z "$FUNCTION" ] ; then
+ echo "testing $FILETOTEST $FUNCTION"
+ $PHPUNIT --bootstrap bootstrap.php --verbose --color --filter $FUNCTION
$FILETOTEST
+else
+
+ $PHPUNIT --bootstrap bootstrap.php --color $FILETOTEST
+fi
+
- [Noalyss-commit] [noalyss] 01/27: documentation, (continued)
- [Noalyss-commit] [noalyss] 01/27: documentation, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 06/27: Code Cleaning : remove direct access to global , add Exception, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 25/27: TEST fix bug in acc_balanceTest, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 13/27: TEST : Acc_Ledger_History*, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 14/27: Facility : new function to help with phpunit, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 26/27: Documentation, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 15/27: Facility improve page_start, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 22/27: Merge branch 'dev-7200', Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 21/27: Bug : export PDF for PRINTTVA doesn't print all the ledgers, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 17/27: Documentation, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 07/27: TEST : add new files,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 19/27: PRINTTVA : cosmetic bug, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 27/27: Merge branch 'dev-7200', Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 20/27: TEST : update, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 16/27: TEST : Acc_Ledger_Purchase + Acc_Ledger_Sale, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 24/27: Documentation, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 23/27: TEST fix bug in acc_balanceTest, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 11/27: Acc_Ledger_History : add documentation, Dany De Bontridder, 2019/11/02
- [Noalyss-commit] [noalyss] 18/27: TEST, Dany De Bontridder, 2019/11/02