diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 12aa8d09dc96a781726085d16cd39579c835315d..0af1e05c9fa36721407bf10bb7fc2d4d23c4811a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2090,9 +2090,10 @@ class Societe extends CommonObject /** * Renvoi url de verification d'un identifiant professionnal - * @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) - * @param soc Objet societe - * @return string url ou chaine vide si aucune url connue + * + * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) + * @param Societe $soc Objet societe + * @return string url ou chaine vide si aucune url connue * TODO not in business class */ function id_prof_url($idprof,$soc) @@ -2112,8 +2113,9 @@ class Societe extends CommonObject } /** - * \brief Indique si la societe a des projets - * \return bool true si la societe a des projets, false sinon + * Indique si la societe a des projets + * + * @return bool true si la societe a des projets, false sinon */ function has_projects() { @@ -2136,28 +2138,10 @@ class Societe extends CommonObject /** - * Add permissions - * @param user_id - * @param read - * @param write - * @param perms - */ - function AddPerms($user_id, $read, $write, $perms) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_perms"; - $sql .= " (fk_soc, fk_user, pread, pwrite, pperms) "; - $sql .= " VALUES (".$this->id.",".$user_id.",".$read.",".$write.",".$perms.");"; - - $resql=$this->db->query($sql); - if ($resql) - { - - } - } - - /** - * Charge les informations d'ordre info dans l'objet societe - * @param id Id de la societe a charger + * Charge les informations d'ordre info dans l'objet societe + * + * @param int $id Id de la societe a charger + * @return void */ function info($id) { diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index b2ddcd1af5a4aa61f1308041c3ef9a5c6d0fee36..44237f83adb64c14235de1ac0e1819a9da8be409 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -119,6 +119,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase } /** + * testSocieteCreate + * + * @return int */ public function testSocieteCreate() { @@ -139,6 +142,11 @@ class SocieteTest extends PHPUnit_Framework_TestCase } /** + * testSocieteFetch + * + * @param int $id Company id + * @return Societe $localobject Company + * * @depends testSocieteCreate * The depends says test is run only if previous is ok */ @@ -163,6 +171,11 @@ class SocieteTest extends PHPUnit_Framework_TestCase } /** + * testSocieteUpdate + * + * @param Societe $localobject Company + * @return Societe $localobject Company + * * @depends testSocieteFetch * The depends says test is run only if previous is ok */ @@ -227,9 +240,69 @@ class SocieteTest extends PHPUnit_Framework_TestCase } /** + * testIdProfCheck + * + * @param Societe $localobject Company + * @return Societe $localobject Company + * * @depends testSocieteUpdate * The depends says test is run only if previous is ok */ + public function testIdProfCheck($localobject) + { + // OK FR + $localobject->country_code='FR'; + $localobject->idprof1=493861496; + $localobject->idprof2=49386149600021; + $result=$localobject->id_prof_check(1,$localobject); // Must be > 0 + print __METHOD__." true idprof1 result=".$result."\n"; + $this->assertGreaterThanOrEqual(1, $result); + $result=$localobject->id_prof_check(2,$localobject); // Must be > 0 + print __METHOD__." true idprof2 result=".$result."\n"; + $this->assertGreaterThanOrEqual(1, $result); + + // KO FR + $localobject->country_code='FR'; + $localobject->idprof1='id1ko'; + $localobject->idprof2='id2ko'; + $result=$localobject->id_prof_check(1,$localobject); // Must be <= 0 + print __METHOD__." wrong idprof1 result=".$result."\n"; + $this->assertLessThan(1, $result); + $result=$localobject->id_prof_check(2,$localobject); // Must be <= 0 + print __METHOD__." wrong idprof2 result=".$result."\n"; + $this->assertLessThan(1, $result); + + // KO ES + $localobject->country_code='ES'; + $localobject->idprof1='id1ko'; + $result=$localobject->id_prof_check(1,$localobject); // Must be <= 0 + print __METHOD__." wrong idprof1 result=".$result."\n"; + $this->assertLessThan(1, $result); + + // OK AR + $localobject->country_code='AR'; + $localobject->idprof1='id1ko'; + $localobject->idprof2='id2ko'; + $result=$localobject->id_prof_check(1,$localobject); // Must be > 0 + print __METHOD__." idprof1 result=".$result."\n"; + $this->assertGreaterThanOrEqual(0, $result); + $result=$localobject->id_prof_check(2,$localobject); // Must be > 0 + print __METHOD__." idprof2 result=".$result."\n"; + $this->assertGreaterThanOrEqual(1, $result); + + return $localobject; + } + + + /** + * testSocieteOther + * + * @param Societe $localobject Company + * @return int $id Id of company + * + * @depends testIdProfCheck + * The depends says test is run only if previous is ok + */ public function testSocieteOther($localobject) { global $conf,$user,$langs,$db; @@ -266,30 +339,15 @@ class SocieteTest extends PHPUnit_Framework_TestCase print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; $this->assertNotEquals($localobject->date_creation, ''); - $localobject->country_code='FR'; - $localobject->idprof1=493861496; - $localobject->idprof2=49386149600021; - $result=$localobject->id_prof_check(1,$localobject); - print __METHOD__." true idprof1 result=".$result."\n"; - $this->assertLessThan($result, 0); - $result=$localobject->id_prof_check(2,$localobject); - print __METHOD__." true idprof2 result=".$result."\n"; - $this->assertLessThan($result, 0); - - $localobject->country_code='FR'; - $localobject->idprof1='id1ko'; - $localobject->idprof2='id2ko'; - $result=$localobject->id_prof_check(1,$localobject); - print __METHOD__." wrong idprof1 result=".$result."\n"; - $this->assertGreaterThan($result, 0); - $result=$localobject->id_prof_check(2,$localobject); - print __METHOD__." wrong idprof2 result=".$result."\n"; - $this->assertGreaterThan($result, 0); - return $localobject->id; } /** + * testSocieteDelete + * + * @param int $id Id of company + * @return int + * * @depends testSocieteOther * The depends says test is run only if previous is ok */ @@ -312,27 +370,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase } /** - * - */ - /*public function testVerifyNumRef() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - $localobject=new Adherent($this->savdb); - $result=$localobject->ref='refthatdoesnotexists'; - $result=$localobject->VerifyNumRef(); - - print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, 0); - return $result; - }*/ - - - /** + * testSocieteStatic + * + * @return void */ public function testSocieteStatic() {