[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 07/08: PhpUnit test insert and update of alph
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 07/08: PhpUnit test insert and update of alphanumeric accounting |
Date: |
Tue, 30 Aug 2022 03:19:06 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 5ccd0fc3994c176e81ee9633ad8612abca1b2655
Author: Dany De Bontridder <dany@alchimerys.be>
AuthorDate: Mon Aug 29 22:17:54 2022 +0200
PhpUnit test insert and update of alphanumeric accounting
---
unit-test/include/class/ficheTest.php | 72 ++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 2 deletions(-)
diff --git a/unit-test/include/class/ficheTest.php
b/unit-test/include/class/ficheTest.php
index 7bc6670b3..7ab5d4f79 100644
--- a/unit-test/include/class/ficheTest.php
+++ b/unit-test/include/class/ficheTest.php
@@ -15,6 +15,7 @@ class FicheTest extends TestCase
* @var Fiche
*/
protected $object;
+ private $connection;
/**
* Sets up the fixture, for example, opens a network connection.
@@ -24,6 +25,7 @@ class FicheTest extends TestCase
{
include 'global.php';
$this->object = new Fiche($g_connection);
+ $this->connection=$g_connection;
}
/**
@@ -611,12 +613,12 @@ where
}
/**
* @brief test insert of the accounting
- * @testdox testAccountInsert Set of the accounting while inserting
+ * @testdox testAccountInsert Set of the accounting while inserting,
numeric with automatic
* @dataProvider dataAccount
*/
public function testAccountInsert($p_value,$p_expected)
{
- global $g_connection;
+ global $g_connection;
$fiche=$this->build_fiche(2, 'PHPUNIT.ACCOUNT.INSERT');
$fiche->setAttribut(ATTR_DEF_ACCOUNT, $p_value);
Card_Property::update($fiche);
@@ -627,6 +629,72 @@ where
$fiche->remove();
}
+ /**
+ * @testdox testAutomaticAccountingUpdateAlpha test accounting automatic
compute(update) with alphanumeric enable
+ */
+ public function testAutomaticAccountingUpdateAlpha()
+ {
+ global $g_connection;
+ $g_connection->exec_sql("delete from tmp_pcmn where pcm_val like
'600%'");
+ $g_connection->exec_sql("update public.parameter set pr_value = $1
where pr_id=$2",
+ array('Y','MY_ALPHANUM'));
+ $fiche_def=new Fiche_Def($g_connection,2);
+ $fiche_def->set_autocreate(true);
+ $fiche_def->save_class_base('600');
+ $fiche=$this->build_fiche(2,'TESTACCOUNT');
+ $start=$fiche->id;
+
$this->assertEquals('600CARDFORPHPUNIT',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account
not properly created');
+
+ for ( $i=600002; $i < 600999;$i++) {
+ $fiche->setAttribut(ATTR_DEF_NAME,'Card for testing '.$i);
+ $fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
+ Card_Property::update($fiche);
+ $fiche->load();
+
$this->assertEquals("600CARDFORTESTING".$i,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account
not properly created');
+
+
+ }
+
+ $g_connection->exec_sql("delete from tmp_pcmn where pcm_val like
'600%'");
+ $g_connection->exec_sql("delete from fiche_detail where f_id >=
$1",[$start]);
+ $g_connection->exec_sql("delete from fiche where f_id >= $1",[$start]);
+ $g_connection->exec_sql("update public.parameter set pr_value = $1
where pr_id=$2",
+ array('N','MY_ALPHANUM'));
+ }
+ /**
+ * @testdox testAutomaticAccountingInsertAlpha test accounting automatic
compute (insert) with alphanumeric enable
+ */
+ public function testAutomaticAccountingInsertAlpha()
+ {
+
+ global $g_connection;
+ $g_connection->exec_sql("delete from tmp_pcmn where pcm_val like
'600%'");
+ $g_connection->exec_sql("update public.parameter set pr_value = $1
where pr_id=$2",
+ array('Y','MY_ALPHANUM'));
+ $fiche_def=new Fiche_Def($g_connection,2);
+ $fiche_def->set_autocreate(true);
+ $fiche_def->save_class_base('600');
+ $first=true;
+
+ for ( $i=1; $i < 1000;$i++) {
+ $fiche=new Fiche($g_connection);
+ $fiche->insert(2,['av_text1'=>substr($i.' PHPUNIT
'.__FUNCTION__,0,35)],);
+ if ( $first ) {
+ $first=false;
+ $start=$fiche->id;
+ }
+ $fiche->load();
+
$this->assertEquals(substr("600".$i."PHPUNITTESTAUTOMATICACCOUNTINGIN",0,36),$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account
not properly created');
+
+ }
+
+ $g_connection->exec_sql("delete from tmp_pcmn where pcm_val like
'600%'");
+ $g_connection->exec_sql("delete from fiche_detail where f_id >=
$1",[$start]);
+ $g_connection->exec_sql("delete from fiche where f_id >= $1",[$start]);
+ $g_connection->exec_sql("update public.parameter set pr_value = $1
where pr_id=$2",
+ array('N','MY_ALPHANUM'));
+
+ }
/**
* @brief test update of the accounting
* @testdox testAccountUpdate et of the accounting while updating
- [Noalyss-commit] [noalyss] branch master updated (30359ca4b -> 70f91d472), Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 02/08: Cosmetic : small screen keep folder color, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 04/08: Ageing Balance : remove limit date, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 05/08: Translation, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 01/08: Cosmetic : highlight row, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 03/08: php8.1 : compatibility, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 06/08: PhpUnit test for Fiche, Dany De Bontridder, 2022/08/30
- [Noalyss-commit] [noalyss] 07/08: PhpUnit test insert and update of alphanumeric accounting,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 08/08: Improve translation and test, Dany De Bontridder, 2022/08/30