noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 11/30: Improve Test and set the Patch level t


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 11/30: Improve Test and set the Patch level to 181
Date: Sat, 3 Dec 2022 08:35:07 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 6bd4f7217880d4513a290eda7a2bb059fc21ef06
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Nov 20 21:23:36 2022 +0100

    Improve Test and set the Patch level to 181
---
 include/class/fiche_def.class.php         | 25 +++++++++++++------------
 include/constant.php                      |  2 +-
 unit-test/include/class/Fiche_DefTest.php | 22 ++++++++++++++++++++++
 unit-test/include/class/contactTest.php   |  2 +-
 unit-test/include/lib/ac_commonTest.php   |  2 +-
 5 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/include/class/fiche_def.class.php 
b/include/class/fiche_def.class.php
index 9cec31ff5..3d169078f 100644
--- a/include/class/fiche_def.class.php
+++ b/include/class/fiche_def.class.php
@@ -121,8 +121,8 @@ class Fiche_Def
         array($this->id));
         */
         $sql="select * from fiche_def ".
-             " where fd_id=".$this->id;
-        $Ret=$this->cn->exec_sql($sql);
+             " where fd_id= $1";
+        $Ret=$this->cn->exec_sql($sql,[$this->id]);
         if ( ($Max=Database::num_row($Ret)) == 0 )
             return ;
         $row=Database::fetch_array($Ret,0);
@@ -133,8 +133,7 @@ class Fiche_Def
         $this->fd_description=$row['fd_description'];
     }
     /*!
-     **************************************************
-     * \brief  Get all the fiche_def
+    * \brief  Get all the fiche_def
      *
      * \return an array of fiche_def object
      */
@@ -144,17 +143,18 @@ class Fiche_Def
 
         $Ret=$this->cn->exec_sql($sql);
         if ( ($Max=Database::num_row($Ret)) == 0 )
-            return ;
-
+            return array();
+        $all=array();
         for ( $i = 0; $i < $Max;$i++)
         {
             $row=Database::fetch_array($Ret,$i);
-            $this->all[$i]=new Fiche_Def($this->cn,$row['fd_id']);
-            $this->all[$i]->label=$row['fd_label'];
-            $this->all[$i]->class_base=$row['fd_class_base'];
-            $this->all[$i]->fiche_def=$row['frd_id'];
-            $this->all[$i]->create_account=$row['fd_create_account'];
+            $all[$i]=new Fiche_Def($this->cn,$row['fd_id']);
+            $all[$i]->label=$row['fd_label'];
+            $all[$i]->class_base=$row['fd_class_base'];
+            $all[$i]->fiche_def=$row['frd_id'];
+            $all[$i]->create_account=$row['fd_create_account'];
         }
+        return $all;
     }
     /*!
      **************************************************
@@ -196,7 +196,8 @@ $order
 
                require_once NOALYSS_TEMPLATE.'/fiche_def_list.php';
        }
-    /*!\brief Add a fiche category thanks the element from the array
+    /*!
+     * \brief Add a fiche category thanks the element from the array
      * you cannot add twice the same cat. name
      * table : insert into fiche_def
      *         insert into attr_def
diff --git a/include/constant.php b/include/constant.php
index 4353f3926..73d32fdd3 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -116,7 +116,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
 if (!defined("SYSINFO_DISPLAY")) {
     define("SYSINFO_DISPLAY", TRUE);
 }
-define("DBVERSION", 180);
+define("DBVERSION", 181);
 define("MONO_DATABASE", 25);
 define("DBVERSIONREPO", 20);
 define('NOTFOUND', '--not found--');
diff --git a/unit-test/include/class/Fiche_DefTest.php 
b/unit-test/include/class/Fiche_DefTest.php
index c7e95939f..03d0a2908 100644
--- a/unit-test/include/class/Fiche_DefTest.php
+++ b/unit-test/include/class/Fiche_DefTest.php
@@ -198,4 +198,26 @@ class Fiche_DefTest extends Testcase
                            
          $fiche_def->RemoveAttribut([20, 21, 22, 51, 52, 53]);             
     }
+    /**
+    @testdox get a Fiche_Def
+    */
+    function testGet()
+    {
+      global $g_connection;
+      $fiche_def=$this->getFicheDef();
+      $fiche_def->get();
+      $this->assertTrue($fiche_def->label=='Test.card',"Can not retrieve 
label");
+    }
+    
+  /**
+    @testdox get all Fiche_Def
+    */
+    function testGetAll()
+    {
+      global $g_connection;
+      $fiche_def=$this->getFicheDef();
+      $all=$fiche_def->get_all();
+      $this->assertEquals(count($all) , 8 ,"Retrieve an wrong number of 
Fiche_Def");
+    }
+    
 }
diff --git a/unit-test/include/class/contactTest.php 
b/unit-test/include/class/contactTest.php
index 2024c5b1a..5eae96dcb 100644
--- a/unit-test/include/class/contactTest.php
+++ b/unit-test/include/class/contactTest.php
@@ -180,7 +180,7 @@ class ContactTest extends TestCase
         $filename="contact-summary-1.html";
         \Noalyss\Facility::save_file($path,$filename,$r);
         print "File saved into $path/$filename";
-        $this->assertEquals(4988, filesize ($path."/".$filename)," File not 
valide (1)");
+        $this->assertEquals(4988, filesize ($path."/".$filename)," File not 
valide (1) $filename");
         $this->assertEquals(5 , preg_match_all('/<tr class="/',$r)," 1. 
Missing card");
         $contact->filter_company(' fourni ');
         ob_start();
diff --git a/unit-test/include/lib/ac_commonTest.php 
b/unit-test/include/lib/ac_commonTest.php
index 6cdb60209..97646ca4b 100644
--- a/unit-test/include/lib/ac_commonTest.php
+++ b/unit-test/include/lib/ac_commonTest.php
@@ -1,4 +1,4 @@
-2<?php
+<?php
 
 use PHPUnit\Framework\TestCase;
 



reply via email to

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