noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 16/27: TEST : Acc_Ledger_Purchase + Acc_Ledge


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 16/27: TEST : Acc_Ledger_Purchase + Acc_Ledger_Sale
Date: Sat, 2 Nov 2019 18:12:18 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit e86e3957cac303eef8bee8d4ed148cd81ff15809
Author: Dany De Bontridder <address@hidden>
Date:   Sat Nov 2 18:30:04 2019 +0100

    TEST : Acc_Ledger_Purchase + Acc_Ledger_Sale
---
 unit-test/facility.class.php                       |   4 +-
 .../class/acc_ledger_purchaseTest.class.php        |  53 +++------
 .../include/class/acc_ledger_soldTest.class.php    | 125 +++++++++++++++------
 3 files changed, 110 insertions(+), 72 deletions(-)

diff --git a/unit-test/facility.class.php b/unit-test/facility.class.php
index b38c396..c32a55a 100644
--- a/unit-test/facility.class.php
+++ b/unit-test/facility.class.php
@@ -61,8 +61,8 @@ EOF;
      */
     static function save_file($p_dir, $p_file, $p_content)
     {
-        $hFile=fopen($p_dir."/".$p_name, "w+");
-        fwrite($hFile, $content);
+        $hFile=fopen($p_dir."/".$p_file, "w+");
+        fwrite($hFile, $p_content);
         fclose($hFile);
     }
 
diff --git a/unit-test/include/class/acc_ledger_purchaseTest.class.php 
b/unit-test/include/class/acc_ledger_purchaseTest.class.php
index 723bba4..e29421a 100644
--- a/unit-test/include/class/acc_ledger_purchaseTest.class.php
+++ b/unit-test/include/class/acc_ledger_purchaseTest.class.php
@@ -54,6 +54,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
             "sa"=>"p",
             "e_mp"=>0,
             "view_invoice"=>"Enregistrer",
+            "ac"=>"ACH"
         );
     }
 
@@ -131,7 +132,16 @@ class Acc_Ledger_PurchaseTest extends TestCase
      */
     public function testInput()
     {
+        put_global([["key"=>"ac","value"=>"ACH"]]);
         $res=$this->object->input();
+        \Noalyss\Facility::save_file(__DIR__."/file", 
+                "acc_ledger_purchase_input.html",
+                \Noalyss\Facility::page_start().$res);
+        $this->assertContains(
+                '<OPTION VALUE="3" SELECTED>Achat</SELECT>',
+                $res);
+        $this->assertContains('<INPUT TYPE="hidden" id="jrn_type" 
NAME="jrn_type" VALUE="ACH"',$res);
+        $this->assertContains('<td class="num">  <span id="tvac" >0.0</span> 
</td>',$res);
         
     }
 
@@ -142,7 +152,14 @@ class Acc_Ledger_PurchaseTest extends TestCase
     public function testConfirm()
     {
         $array=$this->array;
-        $this->object->confirm($array);
+        $array["p_name"]=
+        $ret=$this->object->confirm($array);
+        \Noalyss\Facility::save_file(__DIR__."/file", 
+                "acc_ledger_purchase_confirm.html",
+                \Noalyss\Facility::page_start().$ret);
+        $this->assertContains('name="amount_t0" value="658.25"',$ret);
+        $this->assertContains("value=\"Efface détail\" 
onClick=\"anc_key_clean('25','','658.25','','','0');",$ret);
+        $this->assertContains('NAME="e_quant0" VALUE="1">',$ret);
     }
 
     private function clean_operation()
@@ -152,40 +169,6 @@ class Acc_Ledger_PurchaseTest extends TestCase
         $g_connection->exec_sql("delete from jrnx where j_grpt not in (select 
jr_grpt_id from jrn)");
     }
 
-    /**
-     * @covers Acc_Ledger_Purchase::extra_info
-     * @todo   Implement testExtra_info().
-     */
-    public function testExtra_info()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Acc_Ledger_Purchase::get_detail_purchase
-     * @todo   Implement testGet_detail_purchase().
-     */
-    public function testGet_detail_purchase()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
 
-    /**
-     * @covers Acc_Ledger_Purchase::heading_detail_purchase
-     * @todo   Implement testHeading_detail_purchase().
-     */
-    public function testHeading_detail_purchase()
-    {
-        // 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_soldTest.class.php 
b/unit-test/include/class/acc_ledger_soldTest.class.php
index 192a5b4..ec31e9d 100644
--- a/unit-test/include/class/acc_ledger_soldTest.class.php
+++ b/unit-test/include/class/acc_ledger_soldTest.class.php
@@ -1,4 +1,5 @@
 <?php
+
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -14,6 +15,12 @@ class Acc_Ledger_SoldTest extends TestCase
     protected $object;
 
     /**
+     * Data to include 
+     * @var type 
+     */
+    private $array;
+
+    /**
      * Sets up the fixture, for example, opens a network connection.
      * This method is called before a test is executed.
      */
@@ -21,6 +28,46 @@ class Acc_Ledger_SoldTest extends TestCase
     {
         include 'global.php';
         $this->object=new Acc_Ledger_Sold($g_connection, 2);
+        $this->array=array(
+            "ledger_type"=>"VEN",
+            "ac"=>"COMPTA/VENMENU/VEN",
+            "sa"=>"p",
+            "gDossier"=>25,
+            "nb_item"=>2,
+            "p_jrn"=>2,
+            "p_jrn_predef"=>2,
+            "action"=>"use_opd",
+            "jrn_type"=>"VEN",
+            "filter"=>"",
+            "e_date"=>"24.04.2018",
+            "e_ech"=>"",
+            "e_client"=>"CLIENT",
+            "e_pj"=>"VEN10",
+            "e_pj_suggest"=>"VEN10",
+            "e_comm"=>"Vente Service",
+            "e_march0"=>"DEPLAC",
+            "e_march0_price"=>20,
+            "e_quant0"=>1.21,
+            "htva_march0"=>24.2,
+            "e_march0_tva_id"=>1,
+            "e_march0_tva_amount"=>5.08,
+            "tva_march0"=>5.08,
+            "tvac_march0"=>29.28,
+            "e_march1"=>"MARCHA",
+            "e_march1_price"=>48.5,
+            "e_quant1"=>25,
+            "htva_march1"=>1212.5,
+            "e_march1_tva_id"=>1,
+            "e_march1_tva_amount"=>254.63,
+            "tva_march1"=>254.63,
+            "tvac_march1"=>1467.13,
+            "mp_date"=>"",
+            "acompte"=>0,
+            "e_comm_paiement"=>"",
+            "e_mp"=>"0",
+            "e_mp_qcode_1"=>"COMPTE",
+            "e_mp_qcode_2"=>"",
+            "view_invoice"=>"Enregistrer");
     }
 
     /**
@@ -31,62 +78,61 @@ class Acc_Ledger_SoldTest extends TestCase
     {
         
     }
-
+    private function clean_operation()
+    {
+        global $g_connection;
+        $g_connection->exec_sql("delete from jrn where jr_mt=$1", 
["1572714478.3155"]);
+        $g_connection->exec_sql("delete from jrnx where j_grpt not in (select 
jr_grpt_id from jrn)");
+    }
     /**
      * @covers Acc_Ledger_Sold::verify
-     * @todo   Implement testVerify().
-     * @expectedException Exception
      */
     public function testVerify()
     {
-        $this->object->verify(array());
+        $this->object->verify_operation($this->array);
     }
 
     /**
      * @covers Acc_Ledger_Sold::insert
-     * @todo   Implement testInsert().
-     * @expectedException Exception
      */
     public function testInsert()
     {
-        $this->object->insert(array());
+        global $g_connection;
+        $array=$this->array;
+        $array["pa_id"]=array(2);
+        $array["op"]=array(0, 1);
+        $array["amount_t0"]=24.2;
+        $array["hplan"]=array(array(-1), array(-1));
+        $array["val"]=array(array(24, 2), array(1212.5));
+        $array["mt"]="1572714478.3155";
+        $this->clean_operation();
+        $cnt=$g_connection->get_value("select count(*) from jrn where 
jr_mt=$1",["1572714478.3155"]);
+        $this->assertEquals(0,$cnt);
+        $this->object->insert($array);
+        
+        $cnt=$g_connection->get_value("select count(*) from jrn where 
jr_mt=$1",["1572714478.3155"]);
+        $this->assertEquals(1,$cnt);
+        $this->clean_operation();
     }
 
     /**
      * @covers Acc_Ledger_Sold::confirm
-     * @todo   Implement testConfirm().
-     * @expectedException Exception
      */
     public function testConfirm()
     {
-        $_POST['p_jrn']=$this->object->id;
-        $this->object->confirm(array());
+        $array=$this->array;
+        $res=$this->object->confirm($array);
+        \Noalyss\Facility::save_file(__DIR__."/file"
+                , "acc_ledger_sold_confirm.html"
+                , \Noalyss\Facility::page_start().$res);
+        $this->assertContains(
+                '<input type="button" class="button" value="Vérifiez 
Imputation Analytique" onClick="verify_ca(\'\');">',
+                $res);
+        $this->assertContains('id="e_march1_tva_id" NAME="e_march1_tva_id" 
VALUE="1"', $res);
+        $this->assertContains("anc_key_choice(25,'t1',1212.5,'');", $res);
     }
 
-    /**
-     * @covers Acc_Ledger_Sold::extra_info
-     * @todo   Implement testExtra_info().
-     */
-    public function testExtra_info()
-    {
-        $info=$this->object->extra_info();
-        if (!is_string($info))
-        {
-            $this->assertTrue(FALSE);
-        }
-    }
 
-    /**
-     * @covers Acc_Ledger_Sold::show_unpaid
-     * @todo   Implement testShow_unpaid().
-     */
-    public function testShow_unpaid()
-    {
-        // OBSOLETE : must be removed
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
 
     /**
      * @covers Acc_Ledger_Sold::input
@@ -95,11 +141,20 @@ class Acc_Ledger_SoldTest extends TestCase
     public function testInput()
     {
         $_REQUEST['ac']='VEN';
-        $info=$this->object->input();
+        $info=$this->object->input($this->array);
         if (!is_string($info))
         {
             $this->assertTrue(FALSE);
         }
+        \Noalyss\Facility::save_file(__DIR__."/file", 
"acc_ledger_sold_input.html",
+                \Noalyss\Facility::page_start().
+                $info);
+        $this->assertContains(
+                'NAME="e_client" ID="e_client" VALUE="CLIENT" SIZE="20"  
ondblclick="fill_ipopcard(this);" ', $info);
+        $this->assertContains(
+                '<INPUT TYPE="TEXT"  class="input_text"  id="e_pj" name="e_pj" 
value="VEN10" placeholder="" title=""',
+                $info);
+        $this->assertContains('ID="add_item" VALUE="Ajout article"  
onClick="ledger_add_row()">', $info);
     }
 
     /**



reply via email to

[Prev in Thread] Current Thread [Next in Thread]