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
729a8017
Commit
729a8017
authored
12 years ago
by
Marcos García de La Fuente
Browse files
Options
Downloads
Patches
Plain Diff
Added test for Adherent class functions setUserId and setThirdPartyId
parent
22dcb7ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/phpunit/AdherentTest.php
+98
-5
98 additions, 5 deletions
test/phpunit/AdherentTest.php
with
98 additions
and
5 deletions
test/phpunit/AdherentTest.php
+
98
−
5
View file @
729a8017
...
...
@@ -139,7 +139,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
/**
* testAdherentFetch
*
* @param int $id Id of object to fe
c
th
* @param int $id Id of object to fet
c
h
* @return object Fetched object
*
* @depends testAdherentCreate
...
...
@@ -225,6 +225,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$localobject
->
town
,
$newobject
->
town
);
$this
->
assertEquals
(
$localobject
->
country_id
,
$newobject
->
country_id
);
$this
->
assertEquals
(
'BE'
,
$newobject
->
country_code
);
$this
->
assertEquals
(
'Belgium'
,
$newobject
->
country
);
$this
->
assertEquals
(
$localobject
->
statut
,
$newobject
->
statut
);
$this
->
assertEquals
(
$localobject
->
phone
,
$newobject
->
phone
);
$this
->
assertEquals
(
$localobject
->
phone_perso
,
$newobject
->
phone_perso
);
...
...
@@ -233,7 +234,8 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$localobject
->
naiss
,
$timestamp
);
$this
->
assertEquals
(
$localobject
->
morphy
,
$newobject
->
morphy
);
return
$localobject
;
//We return newobject because of new values
return
$newobject
;
}
/**
...
...
@@ -258,8 +260,8 @@ class AdherentTest extends PHPUnit_Framework_TestCase
'%NOM%,%SOCIETE%,%ADRESSE%,%CP%,%VILLE%,%PAYS%'
;
$expected
=
DOL_MAIN_URL_ROOT
.
','
.
$localobject
->
id
.
',0,New firstname,New name,New firstname New name,'
.
'New company,New address,New zip,New town,,newemail@newemail.com,'
.
dol_print_date
(
$localobject
->
naiss
,
'day'
)
.
',,'
.
'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,'
;
'New company,New address,New zip,New town,
Belgium
,newemail@newemail.com,'
.
dol_print_date
(
$localobject
->
naiss
,
'day'
)
.
',,'
.
'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,
Belgium
'
;
$result
=
$localobject
->
makeSubstitution
(
$template
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
...
...
@@ -269,7 +271,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
}
/**
* testAdherent
Vali
d
* testAdherent
SetUserI
d
*
* @param Adherent $localobject Member instance
* @return Adherent
...
...
@@ -277,6 +279,97 @@ class AdherentTest extends PHPUnit_Framework_TestCase
* @depends testAdherentMakeSubstitution
* The depends says test is run only if previous is ok
*/
public
function
testAdherentSetUserId
(
Adherent
$localobject
)
{
global
$conf
,
$user
,
$langs
,
$db
;
$conf
=
$this
->
savconf
;
$user
=
$this
->
savuser
;
$langs
=
$this
->
savlangs
;
$db
=
$this
->
savdb
;
//We associate member with user
$result
=
$localobject
->
setUserId
(
$user
->
id
);
print
__METHOD__
.
" id="
.
$localobject
->
id
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertEquals
(
$result
,
1
);
//We update user object
$user
->
fetch
(
$user
->
id
);
print
__METHOD__
.
" user id="
.
$user
->
id
.
" fk_member="
.
$user
->
fk_member
.
"
\n
"
;
$this
->
assertEquals
(
$user
->
fk_member
,
$localobject
->
id
);
//We remove association with user
$result
=
$localobject
->
setUserId
(
0
);
print
__METHOD__
.
" id="
.
$localobject
->
id
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertEquals
(
$result
,
1
);
//We update user object
$user
->
fetch
(
$user
->
id
);
print
__METHOD__
.
" user id="
.
$user
->
id
.
" fk_member="
.
$user
->
fk_member
.
"
\n
"
;
$this
->
assertNull
(
$user
->
fk_member
);
return
$localobject
;
}
/**
* testAdherentSetThirdPartyId
*
* @param Adherent $localobject Member instance
* @return Adherent
*
* @depends testAdherentSetUserId
* The depends says test is run only if previous is ok
*/
public
function
testAdherentSetThirdPartyId
(
Adherent
$localobject
)
{
global
$conf
,
$user
,
$langs
,
$db
;
$conf
=
$this
->
savconf
;
$user
=
$this
->
savuser
;
$langs
=
$this
->
savlangs
;
$db
=
$this
->
savdb
;
//Create a Third Party
$thirdparty
=
new
Societe
(
$db
);
$thirdparty
->
initAsSpecimen
();
$result
=
$thirdparty
->
create
(
$user
);
print
__METHOD__
.
" id="
.
$localobject
->
id
.
" third party id="
.
$thirdparty
->
id
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertTrue
(
$result
>
0
);
//Set Third Party ID
$result
=
$localobject
->
setThirdPartyId
(
$thirdparty
->
id
);
$this
->
assertEquals
(
$result
,
1
);
print
__METHOD__
.
" id="
.
$localobject
->
id
.
" result="
.
$result
.
"
\n
"
;
//Adherent is updated with new data
$localobject
->
fetch
(
$localobject
->
id
);
$this
->
assertEquals
(
$localobject
->
fk_soc
,
$thirdparty
->
id
);
print
__METHOD__
.
" id="
.
$localobject
->
id
.
" result="
.
$result
.
"
\n
"
;
//We remove the third party association
$result
=
$localobject
->
setThirdPartyId
(
0
);
$this
->
assertEquals
(
$result
,
1
);
//And check if it has been updated
$localobject
->
fetch
(
$localobject
->
id
);
$this
->
assertNull
(
$localobject
->
fk_soc
);
//Now we remove the third party
$result
=
$thirdparty
->
delete
(
$thirdparty
->
id
);
$this
->
assertEquals
(
$result
,
1
);
return
$localobject
;
}
/**
* testAdherentValid
*
* @param Adherent $localobject Member instance
* @return Adherent
*
* @depends testAdherentSetThirdPartyId
* The depends says test is run only if previous is ok
*/
public
function
testAdherentValid
(
Adherent
$localobject
)
{
global
$conf
,
$user
,
$langs
,
$db
;
...
...
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