noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 09/12: Improve PHPUNIT


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 09/12: Improve PHPUNIT
Date: Sat, 17 Sep 2022 08:40:57 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 9de599e9bc4c8dfe478c94014aee05920d3d77eb
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri Sep 16 15:03:08 2022 +0200

    Improve PHPUNIT
---
 .../class/{fiche_def.Test.php => Fiche_DefTest.php} |  0
 unit-test/include/class/followup_detail.Test.php    | 21 +++++++++++++++------
 unit-test/test-file.sh                              |  6 +++---
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/unit-test/include/class/fiche_def.Test.php 
b/unit-test/include/class/Fiche_DefTest.php
similarity index 100%
rename from unit-test/include/class/fiche_def.Test.php
rename to unit-test/include/class/Fiche_DefTest.php
diff --git a/unit-test/include/class/followup_detail.Test.php 
b/unit-test/include/class/followup_detail.Test.php
index da99d80b6..7b64b8640 100644
--- a/unit-test/include/class/followup_detail.Test.php
+++ b/unit-test/include/class/followup_detail.Test.php
@@ -32,7 +32,7 @@ use PHPUnit\Framework\TestCase;
  * @backupGlobals enabled
  * @coversDefaultClass \Follow_Up_Detail
  */
-require DIRTEST.'/global.php';
+
 
 class Follow_Up_DetailTest extends TestCase
 {
@@ -48,7 +48,11 @@ class Follow_Up_DetailTest extends TestCase
      */
     protected function setUp():void
     {
-        include 'global.php';
+        require DIRTEST.'/global.php';
+        global $g_connection;
+        $this->g_connection=$g_connection;
+        $this->assertNotNull($this->g_connection , "Database",'invalide 
ressource');
+        $this->assertEquals(get_class ($this->g_connection) , 
"Database",'invalide ressource');
     }
 
     /**
@@ -62,12 +66,15 @@ class Follow_Up_DetailTest extends TestCase
 
     /**
      * the setUpBeforeClass():void template methods is called before the first 
test of the test case
-     *  class is run 
+     *  class is run
+     *  @backupGlobals enabled
      */
     public static function setUpBeforeClass():void
     {
+
         global $g_connection;
         $g_connection->exec_sql('delete from action_detail');
+
     }
 
     /**
@@ -114,14 +121,16 @@ class Follow_Up_DetailTest extends TestCase
      */
     public function testSQL_Update()
     {
-        global $g_connection;
-         $obj=new Follow_Up_Detail($g_connection);
+
+
+
+         $obj=new Follow_Up_Detail($this->g_connection);
         $this->insert($obj);
         $this->assertTrue($obj->get_parameter("id")>0,"Cannot insert");
         
         $obj->set_parameter('text','TEST UPDATE');
         $obj->save();
-        $reload=new Follow_Up_Detail($g_connection,$obj->get_parameter("id"));
+        $reload=new 
Follow_Up_Detail($this->g_connection,$obj->get_parameter("id"));
         $reload->load();
         $this->assertTrue($reload->get_parameter("text") == 
$obj->get_parameter("text"),"cannot update");
         $reload->delete();
diff --git a/unit-test/test-file.sh b/unit-test/test-file.sh
index dd5de8c9a..5693f6bf4 100755
--- a/unit-test/test-file.sh
+++ b/unit-test/test-file.sh
@@ -54,7 +54,7 @@ fi
 
 if [ ! -z "$FOLDERTEST" -a  -d "$FOLDERTEST" ] ; then
 
-       $PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE --testdox --color 
$FOLDERTEST
+       $PHPINI $PHPUNIT --globals-backup --bootstrap bootstrap.php $COVERAGE 
--testdox --color $FOLDERTEST
        exit $?
 fi
 
@@ -65,12 +65,12 @@ fi
 
 if [ ! -z "$FUNCTION" ] ; then
        echo "testing $FILETOTEST $FUNCTION"
-       $PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --verbose --color 
--filter $FUNCTION $FILETOTEST
+       $PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --globals-backup 
--verbose --color --filter $FUNCTION $FILETOTEST
 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 
        $PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE $FILETOTEST 
--testdox --color $FILETOTEST 
-       #$PHPUNIT --bootstrap bootstrap.php --whitelist=../include 
--coverage-html=coverage $FILETOTEST --testdox-html 
${FILETOTEST%.php}-testdox.html --color $FILETOTEST 
+       #$PHPUNIT --bootstrap bootstrap.php --whitelist=../include 
--globals-backup --coverage-html=coverage $FILETOTEST --testdox-html 
${FILETOTEST%.php}-testdox.html --color $FILETOTEST 
 fi
 



reply via email to

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