[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 23/33: Fix : date before 2000 throws an excep
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 23/33: Fix : date before 2000 throws an exception |
Date: |
Thu, 11 Nov 2021 06:02:49 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit b0f58ab59279a8ce9696b5568ecc4d7a1e21c4fd
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Oct 21 23:46:52 2021 +0200
Fix : date before 2000 throws an exception
---
include/lib/ac_common.php | 2 +-
unit-test/include/lib/ac_commonTest.php | 52 ++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index f706bda..fdd7e19 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -240,7 +240,7 @@ function isDate($p_date)
{
if (strlen(trim($p_date)) == 0)
return null;
- if (preg_match("/^[0-9]{1,2}\.[0-9]{1,2}\.20[0-9]{2}$/", $p_date) == 0)
+ if (preg_match("/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/", $p_date) == 0)
{
return null;
diff --git a/unit-test/include/lib/ac_commonTest.php
b/unit-test/include/lib/ac_commonTest.php
index 25ce794..2a2da0a 100644
--- a/unit-test/include/lib/ac_commonTest.php
+++ b/unit-test/include/lib/ac_commonTest.php
@@ -1,4 +1,4 @@
-<?php
+2<?php
use PHPUnit\Framework\TestCase;
@@ -204,4 +204,54 @@ class Ac_CommonTest extends TestCase
$this->assertEquals($text,$text);
}
+ /**
+ * provides data to testIsDate
+ */
+ function dataIsDate()
+ {
+ return array(
+ ['01.01.1992',1],
+ ['30.02.2001',0],
+ ['15.07.01',0],
+ ['21.08.2001',1]
+ );
+ }
+ /**
+ * @covers IsDate
+ * @testdox isDate
+ * @dataProvider dataIsDate
+ */
+ function testIsDate($p_date,$expected)
+ {
+ $return=($expected==1)?$p_date:null;
+ $this->assertEquals(isDate($p_date),$return,"Test $p_date");
+ }
+ function dataCompareDate ()
+ {
+ return array(
+ ['01.01.1992','05.02.2001',-1],
+ ['01.01.2012','05.02.2001',1],
+ ['05.02.2001','05.02.2001',0]);
+ }
+ /**
+ * @covers cmpDate
+ * @testDox test cmpDate
+ * @dataProvider dataCompareDate
+ */
+ function testCompareDate($p_date,$p_date_2,$p_result)
+ {
+ $cmp=cmpDate($p_date,$p_date_2);
+ switch ( $p_result ) {
+ case 0:
+ $this->assertEquals($cmp,0);
+ break;
+ case 1:
+ $this->assertGreaterThan(0,$cmp);
+ break;
+ case -1:
+ $this->assertLessThan(0,$cmp);
+ break;
+
+ }
+ }
}
- [Noalyss-commit] [noalyss] 05/33: Bug : pour non-assujetti , pas de calcul en devise, (continued)
- [Noalyss-commit] [noalyss] 05/33: Bug : pour non-assujetti , pas de calcul en devise, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 07/33: Bug for reversed operation when currency are used, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 14/33: Typo, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 13/33: Compute.php it happens that the argument are not numeric, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 16/33: Documentation, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 15/33: Bug #2079 : 0002079: Recherche de carte : guillement ne passe pas, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 21/33: Cosmetic #2082 : OD parfois ajout différence de change, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 18/33: Bug : currency_id was nullable script compatible PSQL 10, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 20/33: Cosmetic #0002080 : NOT-FOUND, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 22/33: Cosmetic #0002081: PRINTTVA : l'export PDF de la TVA, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 23/33: Fix : date before 2000 throws an exception,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 25/33: Improve ACC_LEDGER compute internal ledger code in base 36, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 27/33: Operation ANC : Bug with decimal, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 28/33: Bug #2085: Comptabilité analytique : erreur dans les balances croisées, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 29/33: Task #0002087: Improve COMPTA/MENUFIN/FREC, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 30/33: Task #0002088: Export PDF de ANCBCC, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 17/33: Cosmetic bug : if no rows found , throw a warning, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 19/33: Task #0002068: Pas de champ recherche dans la liste de fiches, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 24/33: Gestion->suivi, global administrators can access all the documents. Improve search, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 26/33: Cosmetic Add close button, Dany De Bontridder, 2021/11/11
- [Noalyss-commit] [noalyss] 33/33: CANAL : add symbol for operation : history card & accounting, Dany De Bontridder, 2021/11/11