diff --git a/include/constant.php b/include/constant.php index d157706d8..cb856c36b 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",137); +define ("DBVERSION",138); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/sql/patch/upgrade137.sql b/include/sql/patch/upgrade137.sql new file mode 100644 index 000000000..2d83eb303 --- /dev/null +++ b/include/sql/patch/upgrade137.sql @@ -0,0 +1,6 @@ +begin; +insert into "parameter" (pr_id,pr_value) values ('MY_ANC_FILTER','6,7'); + + +insert into version (val,v_description) values (138,'Analytic improve'); +commit ; \ No newline at end of file diff --git a/unit-test/include/class/noalyss_parameter_folderTest.class.php b/unit-test/include/class/noalyss_parameter_folderTest.class.php new file mode 100644 index 000000000..091830c19 --- /dev/null +++ b/unit-test/include/class/noalyss_parameter_folderTest.class.php @@ -0,0 +1,183 @@ + + +use PHPUnit\Framework\TestCase; +function trim_parameter($p_value){ + return; +} +/** + * Generated by PHPUnit_SkeletonGenerator on 2017-11-26 at 11:24:04. + */ +class Noalyss_Parameter_FolderTest extends TestCase +{ + + protected $object; + private $a_param; + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + * + */ + protected function setUp() + { + global $g_connection, $g_user; + $_REQUEST['gDossier']=DOSSIER; + $g_connection=new Database(DOSSIER); + $g_user=new User($g_connection); + $this->object=new Noalyss_Parameter_Folder($g_connection); + $this->a_param=explode(",","MY_COUNTRY,". + "MY_DEFAULT_ROUND_ERROR_DEB,". + "MY_DEFAULT_ROUND_ERROR_CRED,". + "MY_ANC_FILTER,". + "MY_NAME,". + "MY_TVA,". + "MY_STREET,". + "MY_NUMBER,". + "MY_CP,". + "MY_TEL,". + "MY_PAYS,". + "MY_COMMUNE,". + "MY_FAX,". + "MY_ANALYTIC,". + "MY_STRICT,". + "MY_TVA_USE,". + "MY_PJ_SUGGEST,". + "MY_CHECK_PERIODE,". + "MY_DATE_SUGGEST,". + "MY_ALPHANUM,". + "MY_UPDLAB,". + "MY_STOCK"); + + } + public function testNew() + { + global $g_connection ; + $nb_param=count($this->a_param); + $cnt=$g_connection->get_value("select count(*) from parameter where pr_id like 'MY_%'"); + $this->assertEquals($nb_param,$cnt,"Number of parameters"); + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testcheck() + { + + $a=$this->object->check('MY_STRICT', 0); + $this->assertEquals($a,"N"); + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testcheck_anc_filter() + { + + try { + $this->object->check_anc_filter('6,7'); + $this->assertTrue(TRUE); + } catch (Exception $ex) { + $this->assertTrue(FALSE,'6,7 is valid'); + } + try { + $this->object->check_anc_filter('6,7,8,2'); + $this->assertTrue(TRUE); + } catch (Exception $ex) { + $this->assertTrue(FALSE,'6,7,8,2 is valid'); + } + try { + $this->object->check_anc_filter('6,7,8,2,AA'); + $this->assertTrue(FALSE); + } catch (Exception $ex) { + $this->assertTrue(TRUE,'6,7,8,2 is not valid'); + } + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testupdate() + { + $ok=0; + try { + $this->testsave(); + } catch (Exception $e) + { + $ok=1; + } + $this->assertEquals($ok,0); + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testsave() + { + global $g_connection; + for ($e =0;$e < count($this->a_param);$e++) + { + + $attr=$this->a_param[$e]; + + $old=$this->object->$attr; + switch ($attr) + { + case "MY_STRICT": + $this->object->$attr='Y'; + break; + case "MY_COUNTRY": + $this->object->MY_COUNTRY='XBE'; + break; + case "MY_ANC_FILTER": + $this->object->MY_ANC_FILTER='5,4'; + break; + default: + $this->object->$attr='000'; + break; + } + $this->object->save($this->a_param[$e]); + $cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]); + $this->assertTrue(($cur_value==$this->object->$attr),sprintf("failed : %s cur_value %s expected %s",$attr,$cur_value,$this->object->$attr)); + $this->assertTrue($cur_value != $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old)); + + $this->object->$attr=$old; + $this->object->save($this->a_param[$e]); + $cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]); + $this->assertTrue($cur_value == $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old)); + } + + } + function testMatch_accounting() + { + $this->assertTrue($this->object->match_analytic("612")); + $this->assertTrue($this->object->match_analytic("6")); + $this->assertTrue($this->object->match_analytic("66")); + $this->assertTrue($this->object->match_analytic("71")); + $this->assertTrue($this->object->match_analytic("7")); + $this->assertFalse($this->object->match_analytic("5")); + } +} + +?>