forked from Wavyzz/dolibarr
Qual: Add specific test for all prof id checks.
This commit is contained in:
@@ -2090,9 +2090,10 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi url de verification d'un identifiant professionnal
|
* 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
|
* @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
|
||||||
* @return string url ou chaine vide si aucune url connue
|
* @param Societe $soc Objet societe
|
||||||
|
* @return string url ou chaine vide si aucune url connue
|
||||||
* TODO not in business class
|
* TODO not in business class
|
||||||
*/
|
*/
|
||||||
function id_prof_url($idprof,$soc)
|
function id_prof_url($idprof,$soc)
|
||||||
@@ -2112,8 +2113,9 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Indique si la societe a des projets
|
* Indique si la societe a des projets
|
||||||
* \return bool true si la societe a des projets, false sinon
|
*
|
||||||
|
* @return bool true si la societe a des projets, false sinon
|
||||||
*/
|
*/
|
||||||
function has_projects()
|
function has_projects()
|
||||||
{
|
{
|
||||||
@@ -2136,28 +2138,10 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add permissions
|
* Charge les informations d'ordre info dans l'objet societe
|
||||||
* @param user_id
|
*
|
||||||
* @param read
|
* @param int $id Id de la societe a charger
|
||||||
* @param write
|
* @return void
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
function info($id)
|
function info($id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* testSocieteCreate
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function testSocieteCreate()
|
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
|
* @depends testSocieteCreate
|
||||||
* The depends says test is run only if previous is ok
|
* 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
|
* @depends testSocieteFetch
|
||||||
* The depends says test is run only if previous is ok
|
* 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
|
* @depends testSocieteUpdate
|
||||||
* The depends says test is run only if previous is ok
|
* 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)
|
public function testSocieteOther($localobject)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
@@ -266,30 +339,15 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
|||||||
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
||||||
$this->assertNotEquals($localobject->date_creation, '');
|
$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;
|
return $localobject->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* testSocieteDelete
|
||||||
|
*
|
||||||
|
* @param int $id Id of company
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
* @depends testSocieteOther
|
* @depends testSocieteOther
|
||||||
* The depends says test is run only if previous is ok
|
* The depends says test is run only if previous is ok
|
||||||
*/
|
*/
|
||||||
@@ -312,27 +370,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* testSocieteStatic
|
||||||
*/
|
*
|
||||||
/*public function testVerifyNumRef()
|
* @return void
|
||||||
{
|
|
||||||
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;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
*/
|
||||||
public function testSocieteStatic()
|
public function testSocieteStatic()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user