Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
6acf38b7
Commit
6acf38b7
authored
13 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Qual: Add specific test for all prof id checks.
parent
ce35e1c4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/societe/class/societe.class.php
+11
-27
11 additions, 27 deletions
htdocs/societe/class/societe.class.php
test/phpunit/SocieteTest.php
+81
-41
81 additions, 41 deletions
test/phpunit/SocieteTest.php
with
92 additions
and
68 deletions
htdocs/societe/class/societe.class.php
+
11
−
27
View file @
6acf38b7
...
...
@@ -2090,8 +2090,9 @@ 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
*
* @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
*/
...
...
@@ -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
()
{
...
...
@@ -2135,29 +2137,11 @@ 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
*
* @param int $id Id de la societe a charger
* @return void
*/
function
info
(
$id
)
{
...
...
This diff is collapsed.
Click to expand it.
test/phpunit/SocieteTest.php
+
81
−
41
View file @
6acf38b7
...
...
@@ -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
}
/**
* testSocieteStatic
*
*/
/*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;
}*/
/**
* @return void
*/
public
function
testSocieteStatic
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment